form_tpl.js 49 KB

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