form_tpl.js 52 KB

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