index.vue 17 KB

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