form_tpl.js 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367
  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={4}
  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-item label="所属商户" contentStyle={{ width: '42%' }}>
  760. {this.formData.companyWechatName}
  761. </el-descriptions-item>
  762. </el-descriptions>
  763. <el-descriptions
  764. border
  765. title=""
  766. column={4}
  767. colon={false}
  768. labelStyle={{ width: '8%' }}
  769. contentStyle={{ width: '17%' }}
  770. style="margin-top:-1px"
  771. >
  772. <el-descriptions-item label="网点名称">
  773. <div class="redbordererr">
  774. <el-form-item label="" lebel-width="0px" prop={`websitId`} rules={required}>
  775. <el-select
  776. style="width:100%"
  777. value={this.formData.websitId}
  778. onInput={val => {
  779. this.formData.websitId = val
  780. }}
  781. placeholder="请选择"
  782. disabled={this.formDialogType >= 2}
  783. onChange={val => {
  784. this.formData.items = []
  785. this.formData.storageId = ""
  786. this.formData.storageName = ""
  787. this.cangkuList = []
  788. this.getStorageListPageV2(val)
  789. if (val) {
  790. this.formData['websitName'] = this.getWebsitList.find(item => item.websitId == val).name
  791. } else {
  792. this.formData['websitName'] = ''
  793. }
  794. this.getorderlist()
  795. this.$nextTick(this.jiaoyan)
  796. }}
  797. >
  798. {this.getWebsitList.map(item => (
  799. <el-option key={item.websitId} label={item.name} value={item.websitId}></el-option>
  800. ))}
  801. </el-select>
  802. </el-form-item>
  803. </div>
  804. </el-descriptions-item>
  805. <el-descriptions-item label="供应商名称">
  806. <div class="redbordererr">
  807. <el-form-item label="" lebel-width="0px" prop={`venderId`} rules={required}>
  808. <el-select
  809. style="width:100%"
  810. value={this.formData.venderId}
  811. onInput={val => {
  812. this.formData.venderId = val
  813. }}
  814. placeholder="请选择"
  815. disabled={this.formDialogType >= 2}
  816. onChange={val => {
  817. if (val) {
  818. this.formData['venderName'] = this.listPageV2Data.find(
  819. item => item.venderId == val
  820. ).venderName
  821. } else {
  822. this.formData['venderName'] = ''
  823. }
  824. this.getorderlist()
  825. this.$nextTick(this.jiaoyan)
  826. }}
  827. >
  828. {this.listPageV2Data.map(item => (
  829. <el-option key={item.venderId} label={item.venderName} value={item.venderId}></el-option>
  830. ))}
  831. </el-select>
  832. </el-form-item>
  833. </div>
  834. </el-descriptions-item>
  835. <el-descriptions-item label={!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.$route?.name)?'出库仓库':"入库仓库"}>
  836. <div class="redbordererr">
  837. <el-form-item label="" lebel-width="0px" prop={`storageId`} rules={required}>
  838. <el-select
  839. style="width:100%"
  840. disabled={this.formDialogType === 2 || !(!this.formData.id || (this.formDialogType === 1) || (this.formDialogType === 3 && this.formData.isImport==true && !!this.formData.id))}
  841. value={this.formData.storageId}
  842. onInput={val => {
  843. this.formData.storageId = val
  844. }}
  845. placeholder="请选择"
  846. onChange={val => {
  847. if (val) {
  848. this.formData['storageName'] = this.cangkuList.find(
  849. item => item.storageId == val
  850. )?.storageName
  851. } else {
  852. this.formData['storageName'] = ''
  853. }
  854. if (~['partsStorage', 'partsReturn'].indexOf(this.$route?.name)) {
  855. if (val) {
  856. peijianList({
  857. isShowStockQty: true,
  858. websitId: this.formData.websitId,
  859. storageId: this.formData.storageId,
  860. pageNum: 1,
  861. pageSize: -1,
  862. params: [
  863. { param: 'a.status', compare: '=', value: 'ON' },
  864. { param: 'a.norm_type', compare: '=', value: 'M' }
  865. ]
  866. }).then(res => {
  867. this.peijianList = res.data.records
  868. })
  869. } else {
  870. this.peijianList = []
  871. }
  872. }
  873. this.$nextTick(this.jiaoyan)
  874. }}
  875. >
  876. {this.cangkuList.map(item => (
  877. <el-option key={item.storageId} label={item.storageName} value={item.storageId}></el-option>
  878. ))}
  879. </el-select>
  880. </el-form-item>
  881. </div>
  882. </el-descriptions-item>
  883. <el-descriptions-item label="">
  884. </el-descriptions-item>
  885. </el-descriptions>
  886. {!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.$route?.name) ? (
  887. <el-descriptions
  888. border
  889. title=""
  890. column={4}
  891. colon={false}
  892. labelStyle={{ width: '8%' }}
  893. contentStyle={{ width: '17%' }}
  894. style="margin-top:-1px"
  895. >
  896. <el-descriptions-item label="采购入库单号" contentStyle={{ width: '42%' }}>
  897. <div class="redbordererr">
  898. <el-form-item label="" lebel-width="0px" prop={`purchaseId`}>
  899. <zj-select
  900. style="width:100%"
  901. value={this.formData.purchaseId}
  902. onInput={val => {
  903. this.formData.purchaseId = val
  904. }}
  905. placeholder="请选择"
  906. disabled={this.formDialogType >= 2}
  907. clearable={true}
  908. filterable={true}
  909. blurNoMatchText={true}
  910. blurNoMatchInputBorderColor=""
  911. onChange={val => {
  912. if (val) {
  913. var data = this.websitPurchaseInList.find(item => item.purchaseId == val)
  914. if (data) {
  915. websitPurchaseInDetail({ purchaseId: data.purchaseId }).then(res => {
  916. Object.assign(this.formData, {
  917. items: res.data.items.map((item, index) => ({
  918. ...item,
  919. retQty: '',
  920. retValue: '',
  921. isEditRow: !index
  922. }))
  923. })
  924. var row = this.formData.items[0]
  925. if (
  926. !!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(
  927. this.$route?.name
  928. ) &&
  929. row &&
  930. row.goodsCategoryId
  931. ) {
  932. materialNormList({
  933. isShowStockQty: true,
  934. websitId: this.formData.websitId,
  935. storageId: this.formData.storageId,
  936. pageNum: 1,
  937. pageSize: -1,
  938. params: [
  939. { param: 'b.category_id', compare: '=', value: row.goodsCategoryId },
  940. { param: 'a.status', compare: '=', value: 'ON' }
  941. ]
  942. }).then(res => {
  943. this.materialNormList = res.data.records
  944. })
  945. }
  946. })
  947. return
  948. }
  949. }
  950. this.formData.items = []
  951. this.$nextTick(this.jiaoyan)
  952. }}
  953. >
  954. {this.websitPurchaseInList.map(item => (
  955. <zj-option
  956. key={item.purchaseId}
  957. label={item.showLabel}
  958. value={item.purchaseId}
  959. ></zj-option>
  960. ))}
  961. </zj-select>
  962. </el-form-item>
  963. </div>
  964. </el-descriptions-item>
  965. <el-descriptions-item label="退货数量">
  966. {!~[0, 1].indexOf(this.formDialogType)
  967. ? this.formData.retTotalQty
  968. : this.setNumber(
  969. [
  970. 0,
  971. 0,
  972. 0,
  973. ...this.formData.items.map(row => {
  974. return Number(row.retQty)
  975. })
  976. ].reduce((a, b) => a + b)
  977. )}
  978. </el-descriptions-item>
  979. <el-descriptions-item label="退款金额">
  980. {!~[0, 1].indexOf(this.formDialogType)
  981. ? this.formData.retTotalAmount
  982. : this.setNumber(
  983. [
  984. 0,
  985. 0,
  986. 0,
  987. ...this.formData.items.map(row => {
  988. return Number(row.cost) * Number(row.retQty)
  989. })
  990. ].reduce((a, b) => a + b)
  991. )}
  992. </el-descriptions-item>
  993. </el-descriptions>
  994. ) : null}
  995. <el-descriptions
  996. border
  997. title=""
  998. column={4}
  999. colon={false}
  1000. labelStyle={{ width: '8%' }}
  1001. contentStyle={{ width: '17%' }}
  1002. style="margin-top:-1px"
  1003. >
  1004. <el-descriptions-item label="制单人">{this.formData.createBy}</el-descriptions-item>
  1005. <el-descriptions-item label="制单时间">{this.formData.createTime}</el-descriptions-item>
  1006. <el-descriptions-item label="审核人">{this.formData.confirmBy}</el-descriptions-item>
  1007. <el-descriptions-item label="审核时间">{this.formData.confirmTime}</el-descriptions-item>
  1008. </el-descriptions>
  1009. <el-descriptions
  1010. border
  1011. title=""
  1012. column={4}
  1013. colon={false}
  1014. labelStyle={{ width: '8%' }}
  1015. contentStyle={{ width: '17%' }}
  1016. style="margin-top:-1px"
  1017. >
  1018. <el-descriptions-item label="附件">
  1019. <ImageUpload
  1020. fileList={this.formData.imageUrl}
  1021. uid="imgSrc666_materials_drawing_images"
  1022. limit={1}
  1023. isEdit={this.formDialogType < 2}
  1024. fileType={['image']}
  1025. />
  1026. </el-descriptions-item>
  1027. <el-descriptions-item label="备注" contentStyle={{ width: '67%' }}>
  1028. <el-input
  1029. type="textarea"
  1030. placeholder="请输入内容"
  1031. value={this.formData.remark}
  1032. onInput={val => {
  1033. this.formData.remark = val
  1034. }}
  1035. maxlength="200"
  1036. show-word-limit
  1037. autosize={{ minRows: 6, maxRows: 8 }}
  1038. disabled={this.formDialogType >= 2}
  1039. ></el-input>
  1040. </el-descriptions-item>
  1041. </el-descriptions>
  1042. </div>
  1043. )
  1044. }
  1045. }
  1046. ]
  1047. },
  1048. formItems2() {
  1049. return [
  1050. {
  1051. md: 24,
  1052. isShow: true,
  1053. name: 'slot-component',
  1054. formItemAttributes: {
  1055. label: '',
  1056. prop: 'items',
  1057. 'label-width': '0px',
  1058. rules: [...required]
  1059. },
  1060. render: (h, { props, onInput }) => {
  1061. var { value } = props
  1062. return (
  1063. <div>
  1064. {!!~[0, 1].indexOf(this.formDialogType) ? (
  1065. <div style="margin-bottom:8px">
  1066. <el-button
  1067. onClick={() => {
  1068. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  1069. if (valid || (Object.keys(invalidFields).length == 1 && invalidFields.items)) {
  1070. this.formData.items.map(item => {
  1071. item.isEditRow = false
  1072. })
  1073. this.formData.items.push({
  1074. brand: '',
  1075. companyWechatId: '',
  1076. cost: '',
  1077. costValue: '',
  1078. goodsCategoryId: '',
  1079. goodsCategoryName: '',
  1080. goodsCode: '',
  1081. goodsId: '',
  1082. goodsName: '',
  1083. goodsSpecification: '',
  1084. goodsStockUnit: '',
  1085. goodsType: '',
  1086. note: '',
  1087. parentCategoryId: '',
  1088. parentCategoryName: '',
  1089. productCategory: '',
  1090. purchaseId: '',
  1091. recQty: '',
  1092. retQty: '',
  1093. retValue: '',
  1094. stockQty: '',
  1095. websitId: '',
  1096. websitName: '',
  1097. isEditRow: true
  1098. })
  1099. }
  1100. })
  1101. }}
  1102. >
  1103. 添加
  1104. </el-button>
  1105. </div>
  1106. ) : null}
  1107. <zj-table
  1108. columns={this.columns}
  1109. tableData={this.formData.items}
  1110. tableAttributes={{
  1111. size: 'mini',
  1112. border: true
  1113. }}
  1114. />
  1115. </div>
  1116. )
  1117. }
  1118. }
  1119. ]
  1120. }
  1121. },
  1122. methods: {
  1123. // 表格列解析渲染数据更改
  1124. columnParsing(item, defaultData) {
  1125. if (item.jname === 'imageUrl') {
  1126. defaultData.render = (h, { row, index, column }) => {
  1127. return (
  1128. <div style="padding:0 6px;cursor: pointer;">
  1129. {row.imageUrl
  1130. ? row.imageUrl
  1131. .split(',')
  1132. .map(url => (
  1133. <el-image src={url} preview-src-list={[url]} fit="fit" style="width:80px;height:80px;" />
  1134. ))
  1135. : null}
  1136. </div>
  1137. )
  1138. }
  1139. }
  1140. return defaultData
  1141. },
  1142. // 监听勾选变化
  1143. selectionChange(data) {
  1144. this.recordSelected = data
  1145. },
  1146. // 获取
  1147. getStorageListPageV2(websitId){
  1148. if(websitId){
  1149. storageListPageV2({
  1150. "pageNum":1,
  1151. "pageSize":-1,
  1152. "params":[
  1153. {"param":"a.websit_id","compare":"=","value": websitId},
  1154. {"param":"a.type","compare":"like","value": (()=>{
  1155. if(~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.$route?.name)){
  1156. return "辅材"
  1157. }else if (~['partsStorage', 'partsReturn'].indexOf(this.$route?.name)) {
  1158. return "配件"
  1159. }
  1160. return ""
  1161. })()},
  1162. {"param":"a.status","compare":"=","value":"true"},
  1163. ]
  1164. }).then(res => {
  1165. this.cangkuList = res.data.records
  1166. })
  1167. }
  1168. },
  1169. // 打开
  1170. openForm() {
  1171. this.getStorageListPageV2(this?.formData?.websitId)
  1172. this.getorderlist(false)
  1173. var req = [getWebsit({ type: 'C', status: true })]
  1174. var runs = [
  1175. res => {
  1176. this.getWebsitList = res.data.filter(item => item.type == 'C')
  1177. }
  1178. ]
  1179. if (~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].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. ]
  1191. )
  1192. runs.push(
  1193. ...[
  1194. res => {
  1195. this.listPageV2Data = res.data.records
  1196. }
  1197. ]
  1198. )
  1199. } else if (~['partsStorage', 'partsReturn'].indexOf(this.$route?.name)) {
  1200. req.push(
  1201. ...[
  1202. listPageV2({
  1203. pageNum: 1,
  1204. pageSize: -1,
  1205. params: [
  1206. { param: 'a.status', compare: '=', value: 'ON' },
  1207. { param: 'a.vender_type', compare: 'like', value: '配件' }
  1208. ]
  1209. })
  1210. ]
  1211. )
  1212. runs.push(
  1213. ...[
  1214. res => {
  1215. this.listPageV2Data = res.data.records
  1216. }
  1217. ]
  1218. )
  1219. }
  1220. if (~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.$route?.name)) {
  1221. req.push(
  1222. ...[
  1223. materialCategoryList({
  1224. pageNum: 1,
  1225. pageSize: -1,
  1226. params: [
  1227. { param: 'a.status', compare: '=', value: 'ON' },
  1228. { param: 'a.category_level', compare: '=', value: '1' }
  1229. ]
  1230. }),
  1231. materialCategoryList({
  1232. pageNum: 1,
  1233. pageSize: -1,
  1234. params: [
  1235. { param: 'a.status', compare: '=', value: 'ON' },
  1236. { param: 'a.category_level', compare: '=', value: '2' }
  1237. ]
  1238. })
  1239. ]
  1240. )
  1241. runs.push(
  1242. ...[
  1243. res => {
  1244. this.materialCategoryListL1 = res.data.records
  1245. },
  1246. res => {
  1247. this.materialCategoryListL2 = res.data.records
  1248. }
  1249. ]
  1250. )
  1251. } else if (~['partsStorage', 'partsReturn'].indexOf(this.$route?.name) && this.formData.websitId) {
  1252. req.push(
  1253. ...[
  1254. peijianList({
  1255. isShowStockQty: true,
  1256. websitId: this.formData.websitId,
  1257. storageId: this.formData.storageId,
  1258. pageNum: 1,
  1259. pageSize: -1,
  1260. params: [
  1261. { param: 'a.status', compare: '=', value: 'ON' },
  1262. { param: 'a.norm_type', compare: '=', value: 'M' }
  1263. ]
  1264. })
  1265. ]
  1266. )
  1267. runs.push(
  1268. ...[
  1269. res => {
  1270. this.peijianList = res.data.records
  1271. }
  1272. ]
  1273. )
  1274. }
  1275. Promise.all(req).then(ress => {
  1276. ress.forEach((res, index) => {
  1277. runs[index](res)
  1278. })
  1279. this.formDialog = true
  1280. })
  1281. },
  1282. qkrow(row, data = {}) {
  1283. ;[
  1284. 'goodsStockUnit',
  1285. 'recQty',
  1286. 'retQty',
  1287. 'retValue',
  1288. 'goodsCode',
  1289. 'goodsSpecification',
  1290. 'brand',
  1291. 'productCategory',
  1292. 'cost',
  1293. 'costValue',
  1294. 'stockQty'
  1295. ].map(key => {
  1296. if (row[key] !== undefined) {
  1297. row[key] = data[key] !== undefined ? data[key] : ''
  1298. }
  1299. })
  1300. },
  1301. getorderlist(bool = true) {
  1302. if (this.formData.websitId && this.formData.venderId) {
  1303. if (~['returnAuxiliaryMaterials'].indexOf(this.$route?.name)) {
  1304. if (bool) {
  1305. this.websitPurchaseInList = []
  1306. this.formData.items = []
  1307. this.formData.purchaseId = ''
  1308. }
  1309. websitPurchaseInList({
  1310. pageNum: 1,
  1311. pageSize: -1,
  1312. params: [
  1313. { param: 'a.goods_type', compare: '=', value: 'M' },
  1314. { param: 'a.flag', compare: '=', value: 'OK' },
  1315. { param: 'a.websit_id', compare: '=', value: this.formData.websitId },
  1316. { param: 'a.vender_id', compare: '=', value: this.formData.venderId }
  1317. ]
  1318. }).then(res => {
  1319. this.websitPurchaseInList = res.data.records.map(item => ({
  1320. ...item,
  1321. showLabel: `单号:${item.purchaseId} / 金额:${item.totalAmount} / 时间:${item.createTime.split(' ')[0]}`
  1322. }))
  1323. })
  1324. } else if (~['partsReturn'].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: 'P' },
  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. }
  1346. }
  1347. },
  1348. // 添加
  1349. addData() {
  1350. this.formDialogType = 0
  1351. this.openForm()
  1352. },
  1353. // 关闭弹窗
  1354. formCancel() {
  1355. this.$refs.formRef.$refs.inlineForm.clearValidate()
  1356. this.$data.formData = this.$options.data().formData
  1357. this.formDialog = false
  1358. },
  1359. jiaoyan() {
  1360. this.$refs.formRef.validate((valid, invalidFields, errLabels) => { }, false)
  1361. },
  1362. setNumber(val) {
  1363. return Number(val.toFixed(2))
  1364. }
  1365. }
  1366. }