index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="编号" prop="fNo">
  5. <el-input
  6. v-model="queryParams.fNo"
  7. placeholder="请输入编号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="名称" prop="fName">
  14. <el-input
  15. v-model="queryParams.fName"
  16. placeholder="请输入名称"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="英文名称" prop="fEnam">
  23. <el-input
  24. v-model="queryParams.fEnam"
  25. placeholder="请输入英文名称"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="规格" prop="fSpecs">
  32. <el-input
  33. v-model="queryParams.fSpecs"
  34. placeholder="请输入规格"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="包装规格" prop="fPackagespecs">
  41. <el-input
  42. v-model="queryParams.fPackagespecs"
  43. placeholder="请输入包装规格"
  44. clearable
  45. size="small"
  46. @keyup.enter.native="handleQuery"
  47. />
  48. </el-form-item>
  49. <el-form-item label="颜色" prop="fColor">
  50. <el-input
  51. v-model="queryParams.fColor"
  52. placeholder="请输入颜色"
  53. clearable
  54. size="small"
  55. @keyup.enter.native="handleQuery"
  56. />
  57. </el-form-item>
  58. <el-form-item label="海关编码" prop="fHscode">
  59. <el-input
  60. v-model="queryParams.fHscode"
  61. placeholder="请输入海关编码"
  62. clearable
  63. size="small"
  64. @keyup.enter.native="handleQuery"
  65. />
  66. </el-form-item>
  67. <el-form-item label="包装类型" prop="fPackageid">
  68. <el-input
  69. v-model="queryParams.fPackageid"
  70. placeholder="请输入包装类型"
  71. clearable
  72. size="small"
  73. @keyup.enter.native="handleQuery"
  74. />
  75. </el-form-item>
  76. <el-form-item label="状态" prop="fStatus">
  77. <!--<el-select v-model="queryParams.fStatus" placeholder="请选择状态" clearable size="small">
  78. <el-option label="请选择字典生成" value="" />
  79. </el-select>-->
  80. <el-select
  81. v-model="queryParams.fStatus"
  82. placeholder="商品状态"
  83. clearable
  84. size="small"
  85. style="width: 240px"
  86. >
  87. <el-option
  88. v-for="dict in statusOptions"
  89. :key="dict.dictValue"
  90. :label="dict.dictLabel"
  91. :value="dict.dictValue"
  92. />
  93. </el-select>
  94. </el-form-item>
  95. <el-form-item>
  96. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  97. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  98. </el-form-item>
  99. </el-form>
  100. <el-row :gutter="10" class="mb8">
  101. <el-col :span="1.5">
  102. <el-button
  103. type="primary"
  104. icon="el-icon-plus"
  105. size="mini"
  106. @click="handleAdd"
  107. v-hasPermi="['basicdata:goods:add']"
  108. >新增</el-button>
  109. </el-col>
  110. <el-col :span="1.5">
  111. <el-button
  112. type="success"
  113. icon="el-icon-edit"
  114. size="mini"
  115. :disabled="single"
  116. @click="handleUpdate"
  117. v-hasPermi="['basicdata:goods:edit']"
  118. >修改</el-button>
  119. </el-col>
  120. <el-col :span="1.5">
  121. <el-button
  122. type="danger"
  123. icon="el-icon-delete"
  124. size="mini"
  125. :disabled="multiple"
  126. @click="handleDelete"
  127. v-hasPermi="['basicdata:goods:remove']"
  128. >删除</el-button>
  129. </el-col>
  130. <el-col :span="1.5">
  131. <el-button
  132. type="warning"
  133. icon="el-icon-download"
  134. size="mini"
  135. @click="handleExport"
  136. v-hasPermi="['basicdata:goods:export']"
  137. >导出</el-button>
  138. </el-col>
  139. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  140. </el-row>
  141. <el-table v-loading="loading" :data="goodsList" @selection-change="handleSelectionChange">
  142. <el-table-column type="selection" width="55" align="center" />
  143. <el-table-column type="index" label="序号" align="center"/>
  144. <!--<el-table-column label="存储id" align="center" prop="fTypeid" />--><!-- 后期添加 -->
  145. <el-table-column label="编号" align="center" prop="fNo" />
  146. <el-table-column label="名称" align="center" prop="fName" />
  147. <el-table-column label="英文名称" align="center" prop="fEnam" />
  148. <el-table-column label="规格" align="center" prop="fSpecs" />
  149. <el-table-column label="包装规格" align="center" prop="fPackagespecs" />
  150. <el-table-column label="颜色" align="center" prop="fColor" />
  151. <el-table-column label="海关编码" align="center" prop="fHscode" />
  152. <el-table-column label="包装类型" align="center" prop="fPackageid" />
  153. <el-table-column label="状态" align="center" prop="fStatus" >
  154. <template slot-scope="scope">
  155. <el-switch
  156. v-model="scope.row.fStatus"
  157. active-value="0"
  158. inactive-value="1"
  159. @change="handleStatusChange(scope.row)"
  160. ></el-switch>
  161. </template>
  162. </el-table-column>
  163. <el-table-column label="备注" align="center" prop="remark" />
  164. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
  165. <template slot-scope="scope">
  166. <el-button
  167. size="mini"
  168. type="text"
  169. icon="el-icon-edit"
  170. @click="handleUpdate(scope.row)"
  171. v-hasPermi="['basicdata:goods:edit']"
  172. >修改</el-button>
  173. <el-button
  174. size="mini"
  175. type="text"
  176. icon="el-icon-delete"
  177. @click="handleDelete(scope.row)"
  178. v-hasPermi="['basicdata:goods:remove']"
  179. >删除</el-button>
  180. </template>
  181. </el-table-column>
  182. </el-table>
  183. <pagination
  184. v-show="total>0"
  185. :total="total"
  186. :page.sync="queryParams.pageNum"
  187. :limit.sync="queryParams.pageSize"
  188. @pagination="getList"
  189. />
  190. <!-- 添加或修改商品详情对话框 -->
  191. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="500px" append-to-body>
  192. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  193. <!--<el-form-item label="存储id" prop="fTypeid">
  194. <el-input v-model="form.fTypeid" placeholder="请输入存储id" />
  195. </el-form-item>-->
  196. <el-row>
  197. <el-col :span="12">
  198. <el-form-item label="编号" prop="fNo">
  199. <el-input v-model="form.fNo" placeholder="请输入编号" />
  200. </el-form-item>
  201. </el-col>
  202. <el-col :span="12">
  203. <el-form-item label="名称" prop="fName">
  204. <el-input v-model="form.fName" placeholder="请输入名称" />
  205. </el-form-item>
  206. </el-col>
  207. </el-row>
  208. <el-row>
  209. <el-col :span="12">
  210. <el-form-item label="英文名称" prop="fEnam">
  211. <el-input v-model="form.fEnam" placeholder="请输入英文名称" />
  212. </el-form-item>
  213. </el-col>
  214. <el-col :span="12">
  215. <el-form-item label="规格" prop="fSpecs">
  216. <el-input v-model="form.fSpecs" placeholder="请输入规格" />
  217. </el-form-item>
  218. </el-col>
  219. </el-row>
  220. <el-row>
  221. <el-col :span="12">
  222. <el-form-item label="包装规格" prop="fPackagespecs">
  223. <el-input v-model="form.fPackagespecs" placeholder="请输入包装规格" />
  224. </el-form-item>
  225. </el-col>
  226. <el-col :span="12">
  227. <el-form-item label="颜色" prop="fColor">
  228. <el-input v-model="form.fColor" placeholder="请输入颜色" />
  229. </el-form-item>
  230. </el-col>
  231. </el-row>
  232. <el-row>
  233. <el-col :span="12">
  234. <el-form-item label="海关编码" prop="fHscode">
  235. <el-input v-model="form.fHscode" placeholder="请输入海关编码" />
  236. </el-form-item>
  237. </el-col>
  238. <el-col :span="12">
  239. <el-form-item label="包装类型" prop="fPackageid">
  240. <el-input v-model="form.fPackageid" placeholder="请输入包装类型" />
  241. </el-form-item>
  242. </el-col>
  243. </el-row>
  244. <el-row>
  245. <el-col :span="12">
  246. <el-form-item label="状态">
  247. <!--<el-radio-group v-model="form.fStatus">
  248. <el-radio label="1">请选择字典生成</el-radio>
  249. </el-radio-group>-->
  250. <el-radio-group v-model="form.fStatus">
  251. <el-radio
  252. v-for="dict in statusOptions"
  253. :key="dict.dictValue"
  254. :label="dict.dictValue"
  255. >{{dict.dictLabel}}</el-radio>
  256. </el-radio-group>
  257. </el-form-item>
  258. </el-col>
  259. <el-col :span="12">
  260. <!--<el-form-item label="删除状态" prop="delFlag">
  261. <el-input v-model="form.delFlag" placeholder="请输入删除状态" />
  262. </el-form-item>-->
  263. </el-col>
  264. </el-row>
  265. <el-form-item label="备注" prop="remark">
  266. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  267. </el-form-item>
  268. </el-form>
  269. <div slot="footer" class="dialog-footer">
  270. <el-button type="primary" @click="submitForm">确 定</el-button>
  271. <el-button @click="cancel">取 消</el-button>
  272. </div>
  273. </el-dialog>
  274. </div>
  275. </template>
  276. <script>
  277. import { listGoods, getGoods, delGoods, addGoods, updateGoods,changeGoodsStatus, exportGoods } from "@/api/basicdata/goods";
  278. export default {
  279. name: "Goods",
  280. components: {
  281. },
  282. data() {
  283. return {
  284. // 遮罩层
  285. loading: true,
  286. // 选中数组
  287. ids: [],
  288. // 非单个禁用
  289. single: true,
  290. // 非多个禁用
  291. multiple: true,
  292. // 显示搜索条件
  293. showSearch: true,
  294. // 总条数
  295. total: 0,
  296. // 商品详情表格数据
  297. goodsList: [],
  298. // 弹出层标题
  299. title: "",
  300. // 是否显示弹出层
  301. open: false,
  302. // 备注字典
  303. fIdOptions: [],
  304. // 状态数据字典
  305. statusOptions: [],
  306. // 删除状态字典
  307. delFlagOptions: [],
  308. // 查询参数
  309. queryParams: {
  310. pageNum: 1,
  311. pageSize: 10,
  312. fTypeid: null,
  313. fNo: null,
  314. fName: null,
  315. fEnam: null,
  316. fSpecs: null,
  317. fPackagespecs: null,
  318. fColor: null,
  319. fHscode: null,
  320. fPackageid: null,
  321. fStatus: null,
  322. },
  323. // 表单参数
  324. form: {},
  325. // 表单校验
  326. rules: {
  327. /*fTypeid: [
  328. { required: true, message: "存储id 显示名称 下拉选择类别,一个商品名称对应一个类别,对应t_goodtype的f_id不能为空", trigger: "blur" }
  329. ],*/
  330. fNo: [
  331. { required: true, message: "编号不能为空", trigger: "blur" }
  332. ],
  333. fName: [
  334. { required: true, message: "名称不能为空", trigger: "blur" }
  335. ],
  336. }
  337. };
  338. },
  339. created() {
  340. this.getList();
  341. this.getDicts("data_customer_category").then(response => {
  342. this.fIdOptions = response.data;
  343. });
  344. this.getDicts("data_delete_state").then(response => {
  345. this.delFlagOptions = response.data;
  346. });
  347. this.getDicts("sys_normal_disable").then(response => {
  348. this.statusOptions = response.data;
  349. });
  350. },
  351. methods: {
  352. /** 查询商品详情列表 */
  353. getList() {
  354. this.loading = true;
  355. listGoods(this.queryParams).then(response => {
  356. this.goodsList = response.rows;
  357. this.total = response.total;
  358. this.loading = false;
  359. });
  360. },
  361. // 名称字典翻译
  362. fIdFormat(row, column) {
  363. return this.selectDictLabel(this.fIdOptions, row.fId);
  364. },
  365. // 删除状态字典翻译
  366. delFlagFormat(row, column) {
  367. return this.selectDictLabel(this.delFlagOptions, row.delFlag);
  368. },
  369. // 取消按钮
  370. cancel() {
  371. this.open = false;
  372. this.reset();
  373. },
  374. // 表单重置
  375. reset() {
  376. this.form = {
  377. fId: null,
  378. /* fTypeid: null, 下拉框 后期修改 */
  379. fNo: null,
  380. fName: null,
  381. fEnam: null,
  382. fSpecs: null,
  383. fPackagespecs: null,
  384. fColor: null,
  385. fHscode: null,
  386. fPackageid: null,
  387. fStatus: "0",
  388. delFlag: null,
  389. createBy: null,
  390. createTime: null,
  391. updateBy: null,
  392. updateTime: null,
  393. remark: null
  394. };
  395. this.resetForm("form");
  396. },
  397. // 状态修改
  398. handleStatusChange(row) {
  399. let text = row.fStatus === "0" ? "启用" : "停用";
  400. this.$confirm('确认要"' + text + '""' + row.fName + '"吗?', "警告", {
  401. confirmButtonText: "确定",
  402. cancelButtonText: "取消",
  403. type: "warning"
  404. }).then(function() {
  405. return changeGoodsStatus(row.fId, row.fStatus);
  406. }).then(() => {
  407. this.msgSuccess(text + "成功");
  408. }).catch(function() {
  409. row.fStatus = row.fStatus === "0" ? "1" : "0";
  410. });
  411. },
  412. /** 搜索按钮操作 */
  413. handleQuery() {
  414. this.queryParams.pageNum = 1;
  415. this.getList();
  416. },
  417. /** 重置按钮操作 */
  418. resetQuery() {
  419. this.resetForm("queryForm");
  420. this.handleQuery();
  421. },
  422. // 多选框选中数据
  423. handleSelectionChange(selection) {
  424. this.ids = selection.map(item => item.fId)
  425. this.single = selection.length!==1
  426. this.multiple = !selection.length
  427. },
  428. /** 新增按钮操作 */
  429. handleAdd() {
  430. this.reset();
  431. this.open = true;
  432. this.title = "添加商品详情";
  433. },
  434. /** 修改按钮操作 */
  435. handleUpdate(row) {
  436. this.reset();
  437. const fId = row.fId || this.ids
  438. getGoods(fId).then(response => {
  439. this.form = response.data;
  440. this.open = true;
  441. this.title = "修改商品详情";
  442. });
  443. },
  444. /** 提交按钮 */
  445. submitForm() {
  446. this.$refs["form"].validate(valid => {
  447. if (valid) {
  448. if (this.form.fId != null) {
  449. updateGoods(this.form).then(response => {
  450. this.msgSuccess("修改成功");
  451. this.open = false;
  452. this.getList();
  453. });
  454. } else {
  455. addGoods(this.form).then(response => {
  456. this.msgSuccess("新增成功");
  457. this.open = false;
  458. this.getList();
  459. });
  460. }
  461. }
  462. });
  463. },
  464. /** 删除按钮操作 */
  465. handleDelete(row) {
  466. const fIds = row.fId || this.ids;
  467. this.$confirm('是否确认删除商品详情编号为"' + fIds + '"的数据项?', "警告", {
  468. confirmButtonText: "确定",
  469. cancelButtonText: "取消",
  470. type: "warning"
  471. }).then(function() {
  472. return delGoods(fIds);
  473. }).then(() => {
  474. this.getList();
  475. this.msgSuccess("删除成功");
  476. })
  477. },
  478. /** 导出按钮操作 */
  479. handleExport() {
  480. const queryParams = this.queryParams;
  481. this.$confirm('是否确认导出所有商品详情数据项?', "警告", {
  482. confirmButtonText: "确定",
  483. cancelButtonText: "取消",
  484. type: "warning"
  485. }).then(function() {
  486. return exportGoods(queryParams);
  487. }).then(response => {
  488. this.download(response.msg);
  489. })
  490. }
  491. }
  492. };
  493. </script>