detailsPageEdit.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <template>
  2. <div class="borderless">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <el-button
  6. type="danger"
  7. style="border: none;background: none;color: red"
  8. icon="el-icon-arrow-left"
  9. @click="backToList"
  10. >返回列表
  11. </el-button>
  12. </div>
  13. <el-button
  14. class="el-button--small-yh add-customer-btn"
  15. type="primary"
  16. :disabled="disabled"
  17. @click="editProductInfo"
  18. size="small"
  19. >{{ form.id ? "确认修改" : "确认新增" }}
  20. </el-button>
  21. </div>
  22. <div style="margin-top: 60px">
  23. <containerTitle title="基础信息"></containerTitle>
  24. <basic-container style="margin-bottom: 10px">
  25. <avue-form ref="form" v-model="form" :option="option">
  26. <template slot="goodsTypeId" slot-scope="scope">
  27. <avue-input-tree
  28. v-model="form.goodsTypeId"
  29. :props="{ label: 'title', value: 'id' }"
  30. multiple
  31. placeholder=" "
  32. type="tree"
  33. :dic="dicData"
  34. />
  35. </template>
  36. <template slot="corpId" slot-scope="scope">
  37. <selectComponent
  38. v-model="form.corpId"
  39. :configuration="configuration"
  40. style="width: 100%"
  41. typeData="GYS"
  42. />
  43. </template>
  44. <template slot="artsVision">
  45. <crop-select
  46. v-model="form.artsVision"
  47. @getCorpData="getCorpName"
  48. @getCorpList="getCorpList"
  49. corpType="GS"
  50. :multiple="true"
  51. :collapseTags="true"
  52. ></crop-select>
  53. </template>
  54. <template slot="brand">
  55. <el-select
  56. v-model="form.brand"
  57. clearable
  58. filterable
  59. placeholder="请选择 品牌"
  60. >
  61. <el-option
  62. v-for="(item, index) in brandOption"
  63. :key="index"
  64. :label="item.dictValue"
  65. :value="item.dictValue"
  66. />
  67. </el-select>
  68. </template>
  69. <template slot="cntrVolumn">
  70. <el-input
  71. v-input-limit="2"
  72. v-model="form.cntrVolumn"
  73. clearable
  74. placeholder="请输入 箱立方"
  75. ></el-input>
  76. </template>
  77. <template slot="cartonWeight">
  78. <el-input
  79. v-input-limit="2"
  80. v-model="form.cartonWeight"
  81. clearable
  82. placeholder="请输入 箱重量"
  83. >
  84. <template slot="append">kg</template>
  85. </el-input>
  86. </template>
  87. <template slot="integralMultiples">
  88. <el-input
  89. v-input-limit="2"
  90. v-model="form.integralMultiples"
  91. clearable
  92. placeholder="请输入 积分倍数"
  93. ></el-input>
  94. </template>
  95. <template slot="integral">
  96. <el-input
  97. v-input-limit="2"
  98. v-model="form.integral"
  99. clearable
  100. placeholder="请输入 兑换积分"
  101. ></el-input>
  102. </template>
  103. <template slot="batch">
  104. <el-switch
  105. v-model="form.batch"
  106. active-text="是"
  107. inactive-text="否"
  108. :active-value="1"
  109. :inactive-value="0"
  110. />
  111. </template>
  112. <template slot="unit">
  113. <el-select
  114. v-model="form.unit"
  115. clearable
  116. filterable
  117. placeholder="请选择 计量单位"
  118. >
  119. <el-option
  120. v-for="(item, index) in unitOption"
  121. :key="index"
  122. :label="item.dictValue"
  123. :value="item.dictValue"
  124. />
  125. </el-select>
  126. </template>
  127. </avue-form>
  128. </basic-container>
  129. <containerTitle title="主图附件"></containerTitle>
  130. <c-upload
  131. :data="bankOfDepositData"
  132. display
  133. deleteUrl="/api/blade-client/goodsfiles/delete"
  134. :enumerationValue="160"/>
  135. </div>
  136. </div>
  137. </template>
  138. <script>
  139. import {
  140. getDetail,
  141. updateDetail,
  142. getDeptTree,
  143. priceDelete
  144. } from "@/api/basicData/commodityType";
  145. export default {
  146. props: {
  147. detailData: Object
  148. },
  149. name: "detailsPage",
  150. data() {
  151. return {
  152. configuration: {
  153. multipleChoices: false,
  154. multiple: false,
  155. collapseTags: false,
  156. placeholder: "请点击右边按钮选择",
  157. dicData: []
  158. },
  159. optionTwo:[],
  160. form: {},
  161. bankOfDepositData:[],
  162. disabled: false,
  163. userDialog: false, //供应商导入窗口
  164. dicData: [],
  165. detailsSelect: {},
  166. option: {
  167. menuBtn: false,
  168. labelWidth: 110,
  169. column: [
  170. {
  171. label: "产品编码",
  172. prop: "code",
  173. span: 8,
  174. rules: [
  175. {
  176. required: true,
  177. message: " ",
  178. trigger: "blur"
  179. }
  180. ]
  181. },
  182. {
  183. label: "产品名称",
  184. prop: "cname",
  185. span: 8,
  186. rules: [
  187. {
  188. required: true,
  189. message: " ",
  190. trigger: "blur"
  191. }
  192. ],
  193. slot: true
  194. },
  195. {
  196. label: "产品分类",
  197. prop: "goodsTypeId",
  198. span: 8,
  199. rules: [
  200. {
  201. required: true,
  202. message: " ",
  203. trigger: "blur"
  204. }
  205. ]
  206. },
  207. {
  208. label: "规格",
  209. prop: "typeno", //specs
  210. span: 8,
  211. rules: [
  212. {
  213. required: true,
  214. message: " ",
  215. trigger: "blur"
  216. }
  217. ]
  218. },
  219. {
  220. label: "规格1(花纹)",
  221. prop: "brandItem",
  222. span: 8,
  223. rules: [
  224. {
  225. required: true,
  226. message: " ",
  227. trigger: "blur"
  228. }
  229. ]
  230. },
  231. {
  232. label: "规格2(尺寸)",
  233. prop: "size",
  234. span: 8
  235. },
  236. {
  237. label: "供应商",
  238. prop: "corpId",
  239. span: 16,
  240. rules: [
  241. {
  242. required: true,
  243. message: " ",
  244. trigger: "change"
  245. }
  246. ]
  247. },
  248. {
  249. label: "品牌",
  250. prop: "brand",
  251. span: 8,
  252. rules: [
  253. {
  254. required: true,
  255. message: " ",
  256. trigger: "change"
  257. }
  258. ]
  259. },
  260. {
  261. label: "所属公司",
  262. prop: "artsVision",
  263. span: 16,
  264. rules: [
  265. {
  266. required: false,
  267. message: " ",
  268. trigger: "change"
  269. }
  270. ]
  271. },
  272. {
  273. label: "产地",
  274. prop: "placeProduction",
  275. span: 8,
  276. rules: [
  277. {
  278. required: true,
  279. message: " ",
  280. trigger: "blur"
  281. }
  282. ]
  283. },
  284. {
  285. label: "级别(负荷指数)",
  286. prop: "specsOne",
  287. span: 8,
  288. rules: [
  289. {
  290. required: false,
  291. message: " ",
  292. trigger: "blur"
  293. }
  294. ]
  295. },
  296. {
  297. label: "级别2(速级)",
  298. prop: "specsTwo",
  299. span: 8,
  300. rules: [
  301. {
  302. required: false,
  303. message: " ",
  304. trigger: "blur"
  305. }
  306. ]
  307. },
  308. {
  309. label: "级别3(加强型)",
  310. prop: "level",
  311. span: 8,
  312. rules: [
  313. {
  314. required: false,
  315. message: " ",
  316. trigger: "blur"
  317. }
  318. ]
  319. },
  320. {
  321. label: "箱立方",
  322. prop: "cntrVolumn",
  323. span: 8,
  324. rules: [
  325. {
  326. required: true,
  327. message: " ",
  328. trigger: "blur"
  329. }
  330. ]
  331. },
  332. {
  333. label: "箱重量",
  334. prop: "cartonWeight",
  335. span: 8,
  336. rules: [
  337. {
  338. required: true,
  339. message: " ",
  340. trigger: "blur"
  341. }
  342. ]
  343. },
  344. {
  345. label: "计量单位",
  346. prop: "unit",
  347. span: 8
  348. },
  349. {
  350. label: "辅助单位",
  351. prop: "assistUnit",
  352. span: 8
  353. },
  354. {
  355. label: "状态",
  356. prop: "status",
  357. span: 8,
  358. type: "select",
  359. dicData: [
  360. {
  361. label: "正常",
  362. value: 0
  363. },
  364. {
  365. label: "停用",
  366. value: 1
  367. }
  368. ]
  369. },
  370. {
  371. label: "积分倍数",
  372. prop: "integralMultiples",
  373. span: 8
  374. },
  375. {
  376. label: "兑换积分",
  377. prop: "integral",
  378. span: 8
  379. },
  380. {
  381. label: "按批次号计算",
  382. prop: "batch",
  383. span: 8
  384. },
  385. {
  386. label: "品名快捷查询",
  387. prop: "cnameInt",
  388. span: 8
  389. },
  390. {
  391. label: "平台商品编码",
  392. prop: "terraceCode",
  393. span: 8
  394. },
  395. {
  396. label: "备注",
  397. prop: "remarks",
  398. type: "textarea",
  399. minRows: 2,
  400. span: 24
  401. }
  402. ]
  403. },
  404. unitOption: [], //计量单位数组
  405. brandOption: [], // 品牌数组
  406. };
  407. },
  408. //初始化查询
  409. created() {
  410. this.getWorkDicts('unit').then(res => {
  411. this.unitOption = res.data.data;
  412. })
  413. this.getWorkDicts('brand').then(res => {
  414. this.brandOption = res.data.data;
  415. })
  416. this.$set(this.form, 'status', 0)
  417. getDeptTree().then(res => {
  418. this.dicData = res.data.data;
  419. });
  420. this.$set(this.form, 'integralMultiples', 1)
  421. this.$set(this.form, 'integral', 0)
  422. this.$set(this.form, 'batch', 0)
  423. if (this.detailData.id) {
  424. this.queryData(this.detailData.id)
  425. } else {
  426. this.$set(this.form, "goodsTypeId", this.detailData.goodsTypeId);
  427. }
  428. },
  429. methods: {
  430. queryData(id) {
  431. this.openFullScreen(false, '正在努力的加载...');
  432. getDetail(id).then(res => {
  433. this.form = res.data.data;
  434. this.bankOfDepositData = res.data.data.filesList
  435. delete this.form.filesList
  436. this.form.artsVision = this.form.artsVision ? this.form.artsVision.split(',') : null;
  437. }).finally(() => {
  438. this.openFullScreen(true);
  439. });
  440. },
  441. addSftRow() {
  442. this.sftData.push({
  443. $cellEdit: true,
  444. cname: null,
  445. texture: null,
  446. colour: null,
  447. describe: null,
  448. remarks: null
  449. });
  450. },
  451. rowContactCell(row, index) {
  452. this.$refs.crudContact.rowCell(row, index);
  453. },
  454. rowPurchaseCell(row, index) {
  455. this.$refs.crudPurchase.rowCell(row, index);
  456. },
  457. //修改提交触发
  458. editProductInfo() {
  459. let list = []
  460. if(this.bankOfDepositData.length>0){
  461. for (let item of this.bankOfDepositData){
  462. if (item.version == 0){
  463. list.push(item.version)
  464. }
  465. }
  466. }else {
  467. return this.$message.error("请上传附件!");
  468. }
  469. if (!(list.indexOf('0') !== -1)){
  470. return this.$message.error("附件无主图,请选择其中一个文件属性为主图!");
  471. }
  472. if (new Set(list).size !== list.length){
  473. return this.$message.error("主图重复");
  474. }
  475. this.$refs["form"].validate((valid, done) => {
  476. done();
  477. //校验明细列表
  478. if (valid) {
  479. this.configuration.dicData.forEach(e => {
  480. if (e.id == this.form.corpId) {
  481. this.form.corpName = e.cname;
  482. }
  483. });
  484. if (typeof this.form.goodsTypeId !== 'string') {
  485. this.form.goodsTypeId = this.form.goodsTypeId.join(',')
  486. }
  487. if (!this.form.artsVision) this.$set(this.form, 'artsVisionName', null);
  488. if (this.form.artsVision) {
  489. this.form.artsVision = this.form.artsVision.join(',')
  490. }
  491. const params = {
  492. ...this.form,
  493. filesList:this.bankOfDepositData,
  494. type: 0
  495. };
  496. this.openFullScreen(false, '正在努力的加载...');
  497. updateDetail(params).then(res => {
  498. if (res.data.success) {
  499. this.$message.success("操作成功!");
  500. }
  501. this.form = res.data.data
  502. this.queryData(res.data.data.id)
  503. }).catch(() => {
  504. this.openFullScreen(true);
  505. });
  506. } else {
  507. return false;
  508. }
  509. });
  510. },
  511. //返回列表
  512. backToList() {
  513. this.$emit("goBack");
  514. },
  515. //遮罩层
  516. openFullScreen(res, text) {
  517. const loading = this.$loading({
  518. lock: true,
  519. text: text,
  520. spinner: 'el-icon-loading',
  521. background: 'rgba(0, 0, 0, 0.7)'
  522. });
  523. if (res === true) loading.close();
  524. },
  525. getCorpName(row) {
  526. this.$set(this.form, 'artsVisionName', row.cname);
  527. },
  528. getCorpList(list) {
  529. let arr = []
  530. list.forEach(item => {
  531. arr.push(item.cname)
  532. })
  533. this.$nextTick(() => {
  534. this.$set(this.form, 'artsVisionName', arr.join(','));
  535. })
  536. }
  537. }
  538. };
  539. </script>
  540. <style lang="scss" scoped>
  541. .back-icon {
  542. line-height: 64px;
  543. font-size: 20px;
  544. margin-right: 8px;
  545. }
  546. ::v-deep .el-form-item {
  547. margin-bottom: 8px;
  548. }
  549. .el-dialogDeep {
  550. ::v-deep .el-dialog {
  551. margin: 1vh auto 0 !important;
  552. padding-bottom: 10px !important;
  553. .el-dialog__body,
  554. .el-dialog__footer {
  555. padding-bottom: 0 !important;
  556. padding-top: 0 !important;
  557. }
  558. }
  559. }
  560. </style>