form_tpl.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357
  1. import ImageUpload from '@/components/file-upload'
  2. import { getWebsit } from '@/api/customerManagement.js'
  3. import { listPageV2 } from '@/api/auxiliaryFittings/supplier'
  4. import { materialCategoryList } from '@/api/auxiliaryMaterialClass'
  5. import { materialNormList } from '@/api/auxiliaryPriceManagement'
  6. import { listPageV2 as peijianList } from '@/api/auxiliaryFittings/attachmentProfile'
  7. import {
  8. websitPurchaseInList,
  9. websitPurchaseInImport,
  10. websitPurchaseRetImport,
  11. websitPurchaseInDetail
  12. } from '@/api/purchasingManagement.js'
  13. import { commonTemplateDownload } from '@/api/common.js'
  14. import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
  15. import { storageListPageV2 } from "@/api/storage";
  16. export default {
  17. data() {
  18. return {
  19. // 表格属性
  20. tableAttributes: {
  21. // 启用勾选列
  22. selectColumn: false
  23. },
  24. // 表格事件
  25. tableEvents: {
  26. 'selection-change': this.selectionChange
  27. },
  28. recordSelected: [],
  29. formDialog: false,
  30. formDialogType: 0, // 0:新增, 1:编辑, 2:查看, 3:审核
  31. formDialogTitles: ['新增', '编辑', '查看', '审核'],
  32. pageType: this?.$route?.name,
  33. materialCategoryListL1: [],
  34. materialCategoryListL2: [],
  35. materialNormList: [],
  36. peijianList: [],
  37. websitPurchaseInList: [],
  38. listPageV2Data: [],
  39. cangkuList: []
  40. }
  41. },
  42. computed: {
  43. // 事件组合
  44. optionsEvensGroup() {
  45. return [
  46. [
  47. [
  48. this.optionsEvensAuth('add', {
  49. click: this.addData
  50. })
  51. ]
  52. ],
  53. [
  54. [
  55. this.optionsEvensAuth('template', {
  56. isRole: !!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this?.$route?.name),
  57. click: () => {
  58. commonTemplateDownload({ name: '采购入库模板.xlsx' }, `${this.$route.meta.title}`)
  59. .then(res => {
  60. this.$message({
  61. message: '下载成功',
  62. type: 'success'
  63. })
  64. })
  65. .catch(err => {
  66. this.$message.error('下载失败')
  67. })
  68. }
  69. })
  70. ],
  71. [
  72. this.optionsEvensAuth('imp', ({ moduleName }) => {
  73. return {
  74. isRole: !!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this?.$route?.name),
  75. name: moduleName,
  76. render: () => {
  77. return this.importButton(websitPurchaseInImport, moduleName, { goodsType: this.storageType })
  78. }
  79. }
  80. })
  81. ]
  82. ],
  83. [
  84. [
  85. this.optionsEvensAuth('template', {
  86. isRole: !!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this?.$route?.name),
  87. click: () => {
  88. commonTemplateDownload({ name: '采购退货模板.xlsx' }, `${this.$route.meta.title}`)
  89. .then(res => {
  90. this.$message({
  91. message: '下载成功',
  92. type: 'success'
  93. })
  94. })
  95. .catch(err => {
  96. this.$message.error('下载失败')
  97. })
  98. }
  99. })
  100. ],
  101. [
  102. this.optionsEvensAuth('imp', ({ moduleName }) => {
  103. return {
  104. isRole: !!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this?.$route?.name),
  105. name: moduleName,
  106. render: () => {
  107. return this.importButton(websitPurchaseRetImport, moduleName, { goodsType: this.storageType })
  108. }
  109. }
  110. })
  111. ]
  112. ]
  113. ]
  114. },
  115. moreParameters() {
  116. return [
  117. {
  118. name: '状态',
  119. key: 'flag',
  120. value: this?.$route?.params?.pageCode||'',
  121. conditions: [
  122. {
  123. label: `全部`,
  124. value: ''
  125. },
  126. {
  127. label: `已保存`,
  128. value: 'SAVE'
  129. },
  130. {
  131. label: `已审核`,
  132. value: 'OK'
  133. },
  134. {
  135. label: `失败`,
  136. value: 'FAIL'
  137. }
  138. ]
  139. }
  140. ]
  141. },
  142. columns() {
  143. return [
  144. ...(() => {
  145. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.$route?.name)) {
  146. return [
  147. {
  148. columnAttributes: {
  149. label: '大类名称',
  150. prop: 'parentCategoryId'
  151. },
  152. render: (h, { row, column, index }) => {
  153. return row.isEditRow ? (
  154. <div class="redbordererr">
  155. <el-form-item
  156. label=""
  157. lebel-width="0px"
  158. prop={`items.${index}.parentCategoryId`}
  159. rules={required}
  160. >
  161. <el-select
  162. value={row[column.columnAttributes.prop]}
  163. onInput={val => {
  164. row[column.columnAttributes.prop] = val
  165. }}
  166. onChange={val => {
  167. row['goodsCategoryId'] = ''
  168. row['goodsCategoryName'] = ''
  169. row['goodsId'] = ''
  170. row['goodsName'] = ''
  171. this.materialNormList = []
  172. this.qkrow(row)
  173. if (val) {
  174. row['parentCategoryName'] = this.materialCategoryListL1.find(
  175. item => item.categoryId == val
  176. ).categoryName
  177. } else {
  178. row['parentCategoryName'] = ''
  179. }
  180. this.$nextTick(this.jiaoyan)
  181. }}
  182. placeholder="请选择"
  183. >
  184. {this.materialCategoryListL1.map((item, index_) => (
  185. <el-option key={index_} label={item.categoryName} value={item.categoryId}></el-option>
  186. ))}
  187. </el-select>
  188. </el-form-item>
  189. </div>
  190. ) : (
  191. <div>{row['parentCategoryName']}</div>
  192. )
  193. }
  194. }
  195. ]
  196. }
  197. return []
  198. })(),
  199. ...(() => {
  200. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.$route?.name)) {
  201. return [
  202. {
  203. columnAttributes: {
  204. label: '小类名称',
  205. prop: 'goodsCategoryId'
  206. },
  207. render: (h, { row, column, index }) => {
  208. var selectList = row['parentCategoryId']
  209. ? this.materialCategoryListL2.filter(item => item.parentCategoryId == row['parentCategoryId'])
  210. : []
  211. return row.isEditRow ? (
  212. <div class="redbordererr">
  213. <el-form-item label="" lebel-width="0px" prop={`items.${index}.goodsCategoryId`} rules={required}>
  214. <el-select
  215. value={row[column.columnAttributes.prop]}
  216. onInput={val => {
  217. row[column.columnAttributes.prop] = val
  218. }}
  219. placeholder="请选择"
  220. onChange={val => {
  221. row['goodsId'] = ''
  222. row['goodsName'] = ''
  223. this.qkrow(row)
  224. if (val) {
  225. row['goodsCategoryName'] = selectList.find(item => item.categoryId == val).categoryName
  226. materialNormList({
  227. isShowStockQty: true,
  228. websitId: this.formData.websitId,
  229. pageNum: 1,
  230. pageSize: -1,
  231. params: [
  232. { param: 'b.category_id', compare: '=', value: val },
  233. { param: 'a.status', compare: '=', value: 'ON' }
  234. ]
  235. }).then(res => {
  236. this.materialNormList = res.data.records
  237. })
  238. } else {
  239. this.materialNormList = []
  240. row['goodsCategoryName'] = ''
  241. }
  242. this.$nextTick(this.jiaoyan)
  243. }}
  244. >
  245. {selectList.map((item, index_) => (
  246. <el-option key={index_} label={item.categoryName} value={item.categoryId}></el-option>
  247. ))}
  248. </el-select>
  249. </el-form-item>
  250. </div>
  251. ) : (
  252. <div>{row['goodsCategoryName']}</div>
  253. )
  254. }
  255. }
  256. ]
  257. }
  258. return []
  259. })(),
  260. ...(() => {
  261. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.$route?.name)) {
  262. return [
  263. {
  264. columnAttributes: {
  265. label: '辅材',
  266. prop: 'goodsId'
  267. },
  268. render: (h, { row, column, index }) => {
  269. return row.isEditRow ? (
  270. <div class="redbordererr">
  271. <el-form-item label="" lebel-width="0px" prop={`items.${index}.goodsId`} rules={required}>
  272. <el-select
  273. value={row[column.columnAttributes.prop]}
  274. onInput={val => {
  275. row[column.columnAttributes.prop] = val
  276. }}
  277. placeholder="请选择"
  278. onChange={val => {
  279. if (val) {
  280. var data = this.materialNormList.find(item => item.goodsId == val)
  281. row['goodsName'] = data.goodsName
  282. this.qkrow(row, {
  283. goodsStockUnit: data.goodsStockUnit,
  284. goodsCode: data.goodsCode,
  285. goodsSpecification: data.goodsSpecification,
  286. brand: '',
  287. productCategory: '',
  288. cost: data.cost,
  289. costValue: '',
  290. stockQty: data.stockQty
  291. })
  292. } else {
  293. row['goodsName'] = ''
  294. this.qkrow(row)
  295. }
  296. this.$nextTick(this.jiaoyan)
  297. }}
  298. >
  299. {this.materialNormList
  300. .filter(
  301. item =>
  302. !~[
  303. ...this.formData.items.map(val => val.goodsId).filter(val => val != row.goodsId)
  304. ].indexOf(item.goodsId)
  305. )
  306. .map((item, index_) => (
  307. <el-option key={index_} label={item.goodsName} value={item.goodsId}></el-option>
  308. ))}
  309. </el-select>
  310. </el-form-item>
  311. </div>
  312. ) : (
  313. <div>{row['goodsName']}</div>
  314. )
  315. }
  316. }
  317. ]
  318. }
  319. return []
  320. })(),
  321. ...(() => {
  322. if (!!~['partsStorage', 'partsReturn'].indexOf(this.$route?.name)) {
  323. return [
  324. {
  325. columnAttributes: {
  326. label: '配件',
  327. prop: 'goodsId'
  328. },
  329. render: (h, { row, column, index }) => {
  330. return row.isEditRow ? (
  331. <div class="redbordererr">
  332. <el-form-item label="" lebel-width="0px" prop={`items.${index}.goodsId`} rules={required}>
  333. <el-select
  334. value={row[column.columnAttributes.prop]}
  335. onInput={val => {
  336. row[column.columnAttributes.prop] = val
  337. }}
  338. placeholder="请选择"
  339. onChange={val => {
  340. this.materialNormList = []
  341. if (val) {
  342. var data = this.peijianList.find(item => item.goodsId == val)
  343. row['goodsName'] = data.goodsName
  344. this.qkrow(row, {
  345. goodsStockUnit: data.goodsStockUnit,
  346. goodsCode: data.goodsCode,
  347. goodsSpecification: data.goodsSpecification,
  348. brand: data.brandRelaName,
  349. productCategory: data.productRelaName,
  350. cost: data.cost,
  351. costValue: '',
  352. stockQty: data.stockQty
  353. })
  354. } else {
  355. row['goodsName'] = ''
  356. this.qkrow(row)
  357. }
  358. this.$nextTick(this.jiaoyan)
  359. }}
  360. >
  361. {this.peijianList
  362. .filter(
  363. item =>
  364. !~[
  365. ...this.formData.items.map(val => val.goodsId).filter(val => val != row.goodsId)
  366. ].indexOf(item.goodsId)
  367. )
  368. .map((item, index_) => (
  369. <el-option key={index_} label={item.goodsName} value={item.goodsId}></el-option>
  370. ))}
  371. </el-select>
  372. </el-form-item>
  373. </div>
  374. ) : (
  375. <div>{row['goodsName']}</div>
  376. )
  377. }
  378. }
  379. ]
  380. }
  381. return []
  382. })(),
  383. ...(() => {
  384. if (
  385. !!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(
  386. this.$route?.name
  387. )
  388. ) {
  389. return [
  390. {
  391. columnAttributes: {
  392. label: '单位',
  393. prop: 'goodsStockUnit'
  394. }
  395. }
  396. ]
  397. }
  398. return []
  399. })(),
  400. ...(() => {
  401. if (!!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this.$route?.name)) {
  402. return [
  403. {
  404. columnAttributes: {
  405. label: '数量',
  406. prop: 'recQty'
  407. },
  408. render: (h, { row, column, index }) => {
  409. return row.isEditRow ? (
  410. <div class="redbordererr">
  411. <el-form-item label="" lebel-width="0px" prop={`items.${index}.recQty`} rules={required}>
  412. <el-input
  413. type="number"
  414. value={row[column.columnAttributes.prop]}
  415. onInput={val => {
  416. row[column.columnAttributes.prop] = val
  417. if (val) {
  418. row.costValue = this.setNumber(Number(row.cost) * Number(val))
  419. } else {
  420. row.costValue = ''
  421. }
  422. this.$nextTick(this.jiaoyan)
  423. }}
  424. placeholder="请选择"
  425. ></el-input>
  426. </el-form-item>
  427. </div>
  428. ) : (
  429. <div>{row[column.columnAttributes.prop]}</div>
  430. )
  431. }
  432. }
  433. ]
  434. }
  435. return []
  436. })(),
  437. ...(() => {
  438. if (!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.$route?.name)) {
  439. return [
  440. {
  441. columnAttributes: {
  442. label: '退货数量',
  443. prop: 'retQty'
  444. },
  445. render: (h, { row, column, index }) => {
  446. return row.isEditRow ? (
  447. <div class="redbordererr">
  448. <el-form-item label="" lebel-width="0px" prop={`items.${index}.retQty`} rules={required}>
  449. <el-input
  450. type="number"
  451. value={row[column.columnAttributes.prop]}
  452. onInput={val => {
  453. row[column.columnAttributes.prop] = val
  454. if (val) {
  455. row.retValue = this.setNumber(Number(row.cost) * Number(val))
  456. } else {
  457. row.retValue = ''
  458. }
  459. this.$nextTick(this.jiaoyan)
  460. }}
  461. placeholder="请选择"
  462. ></el-input>
  463. </el-form-item>
  464. </div>
  465. ) : (
  466. <div>{row[column.columnAttributes.prop]}</div>
  467. )
  468. }
  469. }
  470. ]
  471. }
  472. return []
  473. })(),
  474. ...(() => {
  475. if (!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.$route?.name)) {
  476. return [
  477. {
  478. columnAttributes: {
  479. label: '退款金额',
  480. prop: 'retValue'
  481. }
  482. }
  483. ]
  484. }
  485. return []
  486. })(),
  487. ...(() => {
  488. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.$route?.name)) {
  489. return [
  490. {
  491. columnAttributes: {
  492. label: '商品代码',
  493. prop: 'goodsCode'
  494. }
  495. }
  496. ]
  497. }
  498. return []
  499. })(),
  500. ...(() => {
  501. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.$route?.name)) {
  502. return [
  503. {
  504. columnAttributes: {
  505. label: '规格型号',
  506. prop: 'goodsSpecification'
  507. }
  508. }
  509. ]
  510. }
  511. return []
  512. })(),
  513. ...(() => {
  514. if (!!~['partsStorage', 'partsReturn'].indexOf(this.$route?.name)) {
  515. return [
  516. {
  517. columnAttributes: {
  518. label: '配件编码',
  519. prop: 'goodsCode'
  520. }
  521. }
  522. ]
  523. }
  524. return []
  525. })(),
  526. ...(() => {
  527. if (!!~['partsStorage', 'partsReturn'].indexOf(this.$route?.name)) {
  528. return [
  529. {
  530. columnAttributes: {
  531. label: '适用品牌',
  532. prop: 'brand'
  533. }
  534. }
  535. ]
  536. }
  537. return []
  538. })(),
  539. ...(() => {
  540. if (!!~['partsStorage', 'partsReturn'].indexOf(this.$route?.name)) {
  541. return [
  542. {
  543. columnAttributes: {
  544. label: '适用产品大类',
  545. prop: 'productCategory'
  546. }
  547. }
  548. ]
  549. }
  550. return []
  551. })(),
  552. ...(() => {
  553. if (!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.$route?.name)) {
  554. return [
  555. {
  556. columnAttributes: {
  557. label: '采购数量',
  558. prop: 'recQty'
  559. }
  560. }
  561. ]
  562. }
  563. return []
  564. })(),
  565. ...(() => {
  566. if (
  567. !!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(
  568. this.$route?.name
  569. )
  570. ) {
  571. return [
  572. {
  573. columnAttributes: {
  574. label: '采购价格',
  575. prop: 'cost'
  576. },
  577. render: (h, { row, column, index }) => {
  578. return row.isEditRow ? (
  579. <div class="redbordererr">
  580. <el-form-item label="" lebel-width="0px" prop={`items.${index}.cost`} rules={required}>
  581. <el-input
  582. type="number"
  583. value={row[column.columnAttributes.prop]}
  584. onInput={val => {
  585. row[column.columnAttributes.prop] = val
  586. if (!!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this.$route?.name)) {
  587. if (val) {
  588. row.costValue = this.setNumber(Number(row.recQty) * Number(val))
  589. } else {
  590. row.costValue = ''
  591. }
  592. } else if (!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.$route?.name)) {
  593. if (val) {
  594. row.retValue = this.setNumber(Number(row.retQty) * Number(val))
  595. } else {
  596. row.retValue = ''
  597. }
  598. }
  599. this.$nextTick(this.jiaoyan)
  600. }}
  601. placeholder="请选择"
  602. ></el-input>
  603. </el-form-item>
  604. </div>
  605. ) : (
  606. <div>{row[column.columnAttributes.prop]}</div>
  607. )
  608. }
  609. }
  610. ]
  611. }
  612. return []
  613. })(),
  614. ...(() => {
  615. if (
  616. !!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(
  617. this.$route?.name
  618. )
  619. ) {
  620. return [
  621. {
  622. columnAttributes: {
  623. label: '采购金额',
  624. prop: 'costValue'
  625. }
  626. }
  627. ]
  628. }
  629. return []
  630. })(),
  631. ...(() => {
  632. if (
  633. !!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(
  634. this.$route?.name
  635. ) &&
  636. this.formData.flag !== 'OK'
  637. ) {
  638. return [
  639. {
  640. columnAttributes: {
  641. label: '库存数量',
  642. prop: 'stockQty'
  643. }
  644. }
  645. ]
  646. }
  647. return []
  648. })(),
  649. ...(() => {
  650. if (!!~[0, 1].indexOf(this.formDialogType)) {
  651. return [
  652. {
  653. columnAttributes: {
  654. label: '操作',
  655. prop: ''
  656. },
  657. render: (h, { row, column, index }) => {
  658. return (
  659. <div class="operation-btns">
  660. <el-button
  661. type="text"
  662. onClick={() => {
  663. this.formData.items.splice(index, 1)
  664. }}
  665. >
  666. 删除
  667. </el-button>
  668. {row.isEditRow ? (
  669. <el-button
  670. type="text"
  671. onClick={() => {
  672. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  673. if (valid) {
  674. this.formData.items[index].isEditRow = false
  675. }
  676. })
  677. }}
  678. >
  679. 确定
  680. </el-button>
  681. ) : null}
  682. {!row.isEditRow ? (
  683. <el-button
  684. type="text"
  685. onClick={() => {
  686. this.formData.items.map((item, index_) => {
  687. if (index_ == index) {
  688. item.isEditRow = true
  689. if (
  690. !!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(
  691. this.$route?.name
  692. ) &&
  693. row.goodsCategoryId
  694. ) {
  695. materialNormList({
  696. isShowStockQty: true,
  697. websitId: this.formData.websitId,
  698. pageNum: 1,
  699. pageSize: -1,
  700. params: [
  701. { param: 'b.category_id', compare: '=', value: row.goodsCategoryId },
  702. { param: 'a.status', compare: '=', value: 'ON' }
  703. ]
  704. }).then(res => {
  705. this.materialNormList = res.data.records
  706. })
  707. }
  708. } else {
  709. item.isEditRow = false
  710. }
  711. })
  712. }}
  713. >
  714. 编辑
  715. </el-button>
  716. ) : null}
  717. </div>
  718. )
  719. }
  720. }
  721. ]
  722. }
  723. return []
  724. })()
  725. ]
  726. },
  727. formItems1() {
  728. return [
  729. {
  730. md: 24,
  731. isShow: true,
  732. name: 'slot-component',
  733. formItemAttributes: {
  734. label: '',
  735. prop: '',
  736. 'label-width': '0px'
  737. },
  738. render: (h, { props, onInput }) => {
  739. var { value } = props
  740. return (
  741. <div>
  742. <el-descriptions
  743. border
  744. title=""
  745. column={4}
  746. colon={false}
  747. labelStyle={{ width: '8%' }}
  748. contentStyle={{ width: '17%' }}
  749. >
  750. <el-descriptions-item label="单据状态">
  751. {{ SAVE: '保存', OK: '通过', FAIL: '失败' }[this.formData.flag]}
  752. </el-descriptions-item>
  753. <el-descriptions-item label="单据编号">
  754. {(!!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this.$route?.name)
  755. ? this.formData.purchaseId
  756. : this.formData.purchaseRetId) || ''}
  757. </el-descriptions-item>
  758. <el-descriptions-item label="所属商户" contentStyle={{ width: '42%' }}>
  759. {this.formData.companyWechatName}
  760. </el-descriptions-item>
  761. </el-descriptions>
  762. <el-descriptions
  763. border
  764. title=""
  765. column={4}
  766. colon={false}
  767. labelStyle={{ width: '8%' }}
  768. contentStyle={{ width: '17%' }}
  769. style="margin-top:-1px"
  770. >
  771. <el-descriptions-item label="网点名称">
  772. <div class="redbordererr">
  773. <el-form-item label="" lebel-width="0px" prop={`websitId`} rules={required}>
  774. <el-select
  775. style="width:100%"
  776. value={this.formData.websitId}
  777. onInput={val => {
  778. this.formData.websitId = val
  779. }}
  780. placeholder="请选择"
  781. disabled={this.formDialogType >= 2}
  782. onChange={val => {
  783. this.formData.items = []
  784. if (val) {
  785. this.formData['websitName'] = this.getWebsitList.find(item => item.websitId == val).name
  786. } else {
  787. this.formData['websitName'] = ''
  788. }
  789. if (~['partsStorage', 'partsReturn'].indexOf(this.$route?.name)) {
  790. if (val) {
  791. peijianList({
  792. isShowStockQty: true,
  793. websitId: val,
  794. pageNum: 1,
  795. pageSize: -1,
  796. params: [
  797. { param: 'a.status', compare: '=', value: 'ON' },
  798. { param: 'a.norm_type', compare: '=', value: 'M' }
  799. ]
  800. }).then(res => {
  801. this.peijianList = res.data.records
  802. })
  803. } else {
  804. this.peijianList = []
  805. }
  806. }
  807. this.getorderlist()
  808. this.$nextTick(this.jiaoyan)
  809. }}
  810. >
  811. {this.getWebsitList.map(item => (
  812. <el-option key={item.websitId} label={item.name} value={item.websitId}></el-option>
  813. ))}
  814. </el-select>
  815. </el-form-item>
  816. </div>
  817. </el-descriptions-item>
  818. <el-descriptions-item label="供应商名称">
  819. <div class="redbordererr">
  820. <el-form-item label="" lebel-width="0px" prop={`venderId`} rules={required}>
  821. <el-select
  822. style="width:100%"
  823. value={this.formData.venderId}
  824. onInput={val => {
  825. this.formData.venderId = val
  826. }}
  827. placeholder="请选择"
  828. disabled={this.formDialogType >= 2}
  829. onChange={val => {
  830. if (val) {
  831. this.formData['venderName'] = this.listPageV2Data.find(
  832. item => item.venderId == val
  833. ).venderName
  834. } else {
  835. this.formData['venderName'] = ''
  836. }
  837. this.getorderlist()
  838. this.$nextTick(this.jiaoyan)
  839. }}
  840. >
  841. {this.listPageV2Data.map(item => (
  842. <el-option key={item.venderId} label={item.venderName} value={item.venderId}></el-option>
  843. ))}
  844. </el-select>
  845. </el-form-item>
  846. </div>
  847. </el-descriptions-item>
  848. <el-descriptions-item label={!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.$route?.name)?'入库仓库':"出库仓库"}>
  849. <div class="redbordererr">
  850. <el-form-item label="" lebel-width="0px" prop={`storageId`} rules={required}>
  851. <el-select
  852. style="width:100%"
  853. disabled={this.formDialogType === 2 || !(!this.formData.id || (this.formDialogType === 1) || (this.formDialogType === 3 && this.formData.isImport==true && !!this.formData.id))}
  854. value={this.formData.storageId}
  855. onInput={val => {
  856. this.formData.storageId = val
  857. }}
  858. placeholder="请选择"
  859. onChange={val => {
  860. if (val) {
  861. this.formData['storageName'] = this.cangkuList.find(
  862. item => item.storageId == val
  863. )?.storageName
  864. } else {
  865. this.formData['storageName'] = ''
  866. }
  867. }}
  868. >
  869. {this.cangkuList.map(item => (
  870. <el-option key={item.storageId} label={item.storageName} value={item.storageId}></el-option>
  871. ))}
  872. </el-select>
  873. </el-form-item>
  874. </div>
  875. </el-descriptions-item>
  876. <el-descriptions-item label="">
  877. </el-descriptions-item>
  878. </el-descriptions>
  879. {!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.$route?.name) ? (
  880. <el-descriptions
  881. border
  882. title=""
  883. column={4}
  884. colon={false}
  885. labelStyle={{ width: '8%' }}
  886. contentStyle={{ width: '17%' }}
  887. style="margin-top:-1px"
  888. >
  889. <el-descriptions-item label="采购入库单号" contentStyle={{ width: '42%' }}>
  890. <div class="redbordererr">
  891. <el-form-item label="" lebel-width="0px" prop={`purchaseId`}>
  892. <zj-select
  893. style="width:100%"
  894. value={this.formData.purchaseId}
  895. onInput={val => {
  896. this.formData.purchaseId = val
  897. }}
  898. placeholder="请选择"
  899. disabled={this.formDialogType >= 2}
  900. clearable={true}
  901. filterable={true}
  902. blurNoMatchText={true}
  903. blurNoMatchInputBorderColor=""
  904. onChange={val => {
  905. if (val) {
  906. var data = this.websitPurchaseInList.find(item => item.purchaseId == val)
  907. if (data) {
  908. websitPurchaseInDetail({ purchaseId: data.purchaseId }).then(res => {
  909. Object.assign(this.formData, {
  910. items: res.data.items.map((item, index) => ({
  911. ...item,
  912. retQty: '',
  913. retValue: '',
  914. isEditRow: !index
  915. }))
  916. })
  917. var row = this.formData.items[0]
  918. if (
  919. !!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(
  920. this.$route?.name
  921. ) &&
  922. row &&
  923. row.goodsCategoryId
  924. ) {
  925. materialNormList({
  926. isShowStockQty: true,
  927. websitId: this.formData.websitId,
  928. pageNum: 1,
  929. pageSize: -1,
  930. params: [
  931. { param: 'b.category_id', compare: '=', value: row.goodsCategoryId },
  932. { param: 'a.status', compare: '=', value: 'ON' }
  933. ]
  934. }).then(res => {
  935. this.materialNormList = res.data.records
  936. })
  937. }
  938. })
  939. return
  940. }
  941. }
  942. this.formData.items = []
  943. this.$nextTick(this.jiaoyan)
  944. }}
  945. >
  946. {this.websitPurchaseInList.map(item => (
  947. <zj-option
  948. key={item.purchaseId}
  949. label={item.showLabel}
  950. value={item.purchaseId}
  951. ></zj-option>
  952. ))}
  953. </zj-select>
  954. </el-form-item>
  955. </div>
  956. </el-descriptions-item>
  957. <el-descriptions-item label="退货数量">
  958. {!~[0, 1].indexOf(this.formDialogType)
  959. ? this.formData.retTotalQty
  960. : this.setNumber(
  961. [
  962. 0,
  963. 0,
  964. 0,
  965. ...this.formData.items.map(row => {
  966. return Number(row.retQty)
  967. })
  968. ].reduce((a, b) => a + b)
  969. )}
  970. </el-descriptions-item>
  971. <el-descriptions-item label="退款金额">
  972. {!~[0, 1].indexOf(this.formDialogType)
  973. ? this.formData.retTotalAmount
  974. : this.setNumber(
  975. [
  976. 0,
  977. 0,
  978. 0,
  979. ...this.formData.items.map(row => {
  980. return Number(row.cost) * Number(row.retQty)
  981. })
  982. ].reduce((a, b) => a + b)
  983. )}
  984. </el-descriptions-item>
  985. </el-descriptions>
  986. ) : null}
  987. <el-descriptions
  988. border
  989. title=""
  990. column={4}
  991. colon={false}
  992. labelStyle={{ width: '8%' }}
  993. contentStyle={{ width: '17%' }}
  994. style="margin-top:-1px"
  995. >
  996. <el-descriptions-item label="制单人">{this.formData.createBy}</el-descriptions-item>
  997. <el-descriptions-item label="制单时间">{this.formData.createTime}</el-descriptions-item>
  998. <el-descriptions-item label="审核人">{this.formData.confirmBy}</el-descriptions-item>
  999. <el-descriptions-item label="审核时间">{this.formData.confirmTime}</el-descriptions-item>
  1000. </el-descriptions>
  1001. <el-descriptions
  1002. border
  1003. title=""
  1004. column={4}
  1005. colon={false}
  1006. labelStyle={{ width: '8%' }}
  1007. contentStyle={{ width: '17%' }}
  1008. style="margin-top:-1px"
  1009. >
  1010. <el-descriptions-item label="附件">
  1011. <ImageUpload
  1012. fileList={this.formData.imageUrl}
  1013. uid="imgSrc666_materials_drawing_images"
  1014. limit={1}
  1015. isEdit={this.formDialogType < 2}
  1016. fileType={['image']}
  1017. />
  1018. </el-descriptions-item>
  1019. <el-descriptions-item label="备注" contentStyle={{ width: '67%' }}>
  1020. <el-input
  1021. type="textarea"
  1022. placeholder="请输入内容"
  1023. value={this.formData.remark}
  1024. onInput={val => {
  1025. this.formData.remark = val
  1026. }}
  1027. maxlength="200"
  1028. show-word-limit
  1029. autosize={{ minRows: 6, maxRows: 8 }}
  1030. disabled={this.formDialogType >= 2}
  1031. ></el-input>
  1032. </el-descriptions-item>
  1033. </el-descriptions>
  1034. </div>
  1035. )
  1036. }
  1037. }
  1038. ]
  1039. },
  1040. formItems2() {
  1041. return [
  1042. {
  1043. md: 24,
  1044. isShow: true,
  1045. name: 'slot-component',
  1046. formItemAttributes: {
  1047. label: '',
  1048. prop: 'items',
  1049. 'label-width': '0px',
  1050. rules: [...required]
  1051. },
  1052. render: (h, { props, onInput }) => {
  1053. var { value } = props
  1054. return (
  1055. <div>
  1056. {!!~[0, 1].indexOf(this.formDialogType) ? (
  1057. <div style="margin-bottom:8px">
  1058. <el-button
  1059. onClick={() => {
  1060. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  1061. if (valid || (Object.keys(invalidFields).length == 1 && invalidFields.items)) {
  1062. this.formData.items.map(item => {
  1063. item.isEditRow = false
  1064. })
  1065. this.formData.items.push({
  1066. brand: '',
  1067. companyWechatId: '',
  1068. cost: '',
  1069. costValue: '',
  1070. goodsCategoryId: '',
  1071. goodsCategoryName: '',
  1072. goodsCode: '',
  1073. goodsId: '',
  1074. goodsName: '',
  1075. goodsSpecification: '',
  1076. goodsStockUnit: '',
  1077. goodsType: '',
  1078. note: '',
  1079. parentCategoryId: '',
  1080. parentCategoryName: '',
  1081. productCategory: '',
  1082. purchaseId: '',
  1083. recQty: '',
  1084. retQty: '',
  1085. retValue: '',
  1086. stockQty: '',
  1087. websitId: '',
  1088. websitName: '',
  1089. isEditRow: true
  1090. })
  1091. }
  1092. })
  1093. }}
  1094. >
  1095. 添加
  1096. </el-button>
  1097. </div>
  1098. ) : null}
  1099. <zj-table
  1100. columns={this.columns}
  1101. tableData={this.formData.items}
  1102. tableAttributes={{
  1103. size: 'mini',
  1104. border: true
  1105. }}
  1106. />
  1107. </div>
  1108. )
  1109. }
  1110. }
  1111. ]
  1112. }
  1113. },
  1114. methods: {
  1115. // 表格列解析渲染数据更改
  1116. columnParsing(item, defaultData) {
  1117. if (item.jname === 'imageUrl') {
  1118. defaultData.render = (h, { row, index, column }) => {
  1119. return (
  1120. <div style="padding:0 6px;cursor: pointer;">
  1121. {row.imageUrl
  1122. ? row.imageUrl
  1123. .split(',')
  1124. .map(url => (
  1125. <el-image src={url} preview-src-list={[url]} fit="fit" style="width:80px;height:80px;" />
  1126. ))
  1127. : null}
  1128. </div>
  1129. )
  1130. }
  1131. }
  1132. return defaultData
  1133. },
  1134. // 监听勾选变化
  1135. selectionChange(data) {
  1136. this.recordSelected = data
  1137. },
  1138. // 打开
  1139. openForm() {
  1140. this.getorderlist(false)
  1141. var req = [getWebsit({ type: 'C', status: true })]
  1142. var runs = [
  1143. res => {
  1144. this.getWebsitList = res.data.filter(item => item.type == 'C')
  1145. }
  1146. ]
  1147. console.log(this.$route?.name)
  1148. if (~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.$route?.name)) {
  1149. req.push(
  1150. ...[
  1151. listPageV2({
  1152. pageNum: 1,
  1153. pageSize: -1,
  1154. params: [
  1155. { param: 'a.status', compare: '=', value: 'ON' },
  1156. { param: 'a.vender_type', compare: 'like', value: '辅材' }
  1157. ]
  1158. }),
  1159. storageListPageV2({
  1160. "pageNum":1,
  1161. "pageSize":-1,
  1162. "params":[
  1163. {"param":"a.type","compare":"like","value":"辅材"},
  1164. {"param":"a.status","compare":"=","value":"true"}
  1165. ]
  1166. })
  1167. ]
  1168. )
  1169. runs.push(
  1170. ...[
  1171. res => {
  1172. this.listPageV2Data = res.data.records
  1173. },
  1174. res => {
  1175. this.cangkuList = res.data.records
  1176. }
  1177. ]
  1178. )
  1179. } else if (~['partsStorage', 'partsReturn'].indexOf(this.$route?.name)) {
  1180. req.push(
  1181. ...[
  1182. listPageV2({
  1183. pageNum: 1,
  1184. pageSize: -1,
  1185. params: [
  1186. { param: 'a.status', compare: '=', value: 'ON' },
  1187. { param: 'a.vender_type', compare: 'like', value: '配件' }
  1188. ]
  1189. }),
  1190. storageListPageV2({
  1191. "pageNum":1,
  1192. "pageSize":-1,
  1193. "params":[
  1194. {"param":"a.type","compare":"like","value":"配件"},
  1195. {"param":"a.status","compare":"=","value":"true"}
  1196. ]
  1197. })
  1198. ]
  1199. )
  1200. runs.push(
  1201. ...[
  1202. res => {
  1203. this.listPageV2Data = res.data.records
  1204. },
  1205. res => {
  1206. this.cangkuList = res.data.records
  1207. }
  1208. ]
  1209. )
  1210. }
  1211. if (~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.$route?.name)) {
  1212. req.push(
  1213. ...[
  1214. materialCategoryList({
  1215. pageNum: 1,
  1216. pageSize: -1,
  1217. params: [
  1218. { param: 'a.status', compare: '=', value: 'ON' },
  1219. { param: 'a.category_level', compare: '=', value: '1' }
  1220. ]
  1221. }),
  1222. materialCategoryList({
  1223. pageNum: 1,
  1224. pageSize: -1,
  1225. params: [
  1226. { param: 'a.status', compare: '=', value: 'ON' },
  1227. { param: 'a.category_level', compare: '=', value: '2' }
  1228. ]
  1229. })
  1230. ]
  1231. )
  1232. runs.push(
  1233. ...[
  1234. res => {
  1235. this.materialCategoryListL1 = res.data.records
  1236. },
  1237. res => {
  1238. this.materialCategoryListL2 = res.data.records
  1239. }
  1240. ]
  1241. )
  1242. } else if (~['partsStorage', 'partsReturn'].indexOf(this.$route?.name) && this.formData.websitId) {
  1243. req.push(
  1244. ...[
  1245. peijianList({
  1246. isShowStockQty: true,
  1247. websitId: this.formData.websitId,
  1248. pageNum: 1,
  1249. pageSize: -1,
  1250. params: [
  1251. { param: 'a.status', compare: '=', value: 'ON' },
  1252. { param: 'a.norm_type', compare: '=', value: 'M' }
  1253. ]
  1254. })
  1255. ]
  1256. )
  1257. runs.push(
  1258. ...[
  1259. res => {
  1260. this.peijianList = res.data.records
  1261. }
  1262. ]
  1263. )
  1264. }
  1265. Promise.all(req).then(ress => {
  1266. ress.forEach((res, index) => {
  1267. runs[index](res)
  1268. })
  1269. this.formDialog = true
  1270. })
  1271. },
  1272. qkrow(row, data = {}) {
  1273. ;[
  1274. 'goodsStockUnit',
  1275. 'recQty',
  1276. 'retQty',
  1277. 'retValue',
  1278. 'goodsCode',
  1279. 'goodsSpecification',
  1280. 'brand',
  1281. 'productCategory',
  1282. 'cost',
  1283. 'costValue',
  1284. 'stockQty'
  1285. ].map(key => {
  1286. if (row[key] !== undefined) {
  1287. row[key] = data[key] !== undefined ? data[key] : ''
  1288. }
  1289. })
  1290. },
  1291. getorderlist(bool = true) {
  1292. if (this.formData.websitId && this.formData.venderId) {
  1293. if (~['returnAuxiliaryMaterials'].indexOf(this.$route?.name)) {
  1294. if (bool) {
  1295. this.websitPurchaseInList = []
  1296. this.formData.items = []
  1297. this.formData.purchaseId = ''
  1298. }
  1299. websitPurchaseInList({
  1300. pageNum: 1,
  1301. pageSize: -1,
  1302. params: [
  1303. { param: 'a.goods_type', compare: '=', value: 'M' },
  1304. { param: 'a.flag', compare: '=', value: 'OK' },
  1305. { param: 'a.websit_id', compare: '=', value: this.formData.websitId },
  1306. { param: 'a.vender_id', compare: '=', value: this.formData.venderId }
  1307. ]
  1308. }).then(res => {
  1309. this.websitPurchaseInList = res.data.records.map(item => ({
  1310. ...item,
  1311. showLabel: `单号:${item.purchaseId} / 金额:${item.totalAmount} / 时间:${item.createTime.split(' ')[0]}`
  1312. }))
  1313. })
  1314. } else if (~['partsReturn'].indexOf(this.$route?.name)) {
  1315. if (bool) {
  1316. this.websitPurchaseInList = []
  1317. this.formData.items = []
  1318. this.formData.purchaseId = ''
  1319. }
  1320. websitPurchaseInList({
  1321. pageNum: 1,
  1322. pageSize: -1,
  1323. params: [
  1324. { param: 'a.goods_type', compare: '=', value: 'P' },
  1325. { param: 'a.flag', compare: '=', value: 'OK' },
  1326. { param: 'a.websit_id', compare: '=', value: this.formData.websitId },
  1327. { param: 'a.vender_id', compare: '=', value: this.formData.venderId }
  1328. ]
  1329. }).then(res => {
  1330. this.websitPurchaseInList = res.data.records.map(item => ({
  1331. ...item,
  1332. showLabel: `单号:${item.purchaseId} / 金额:${item.totalAmount} / 时间:${item.createTime.split(' ')[0]}`
  1333. }))
  1334. })
  1335. }
  1336. }
  1337. },
  1338. // 添加
  1339. addData() {
  1340. this.formDialogType = 0
  1341. this.openForm()
  1342. },
  1343. // 关闭弹窗
  1344. formCancel() {
  1345. this.$refs.formRef.$refs.inlineForm.clearValidate()
  1346. this.$data.formData = this.$options.data().formData
  1347. this.formDialog = false
  1348. },
  1349. jiaoyan() {
  1350. this.$refs.formRef.validate((valid, invalidFields, errLabels) => { }, false)
  1351. },
  1352. setNumber(val) {
  1353. return Number(val.toFixed(2))
  1354. }
  1355. }
  1356. }