form_tpl.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  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 { websitPurchaseInList, websitPurchaseInImport, websitPurchaseRetImport, websitPurchaseInDetail } from "@/api/purchasingManagement.js"
  8. import { commonTemplateDownload } from '@/api/common.js'
  9. import { required, mobileRequired, mobile } from '@/components/template/rules_verify.js'
  10. export default {
  11. data() {
  12. return {
  13. // 表格属性
  14. tableAttributes: {
  15. // 启用勾选列
  16. selectColumn: false
  17. },
  18. // 表格事件
  19. tableEvents: {
  20. 'selection-change': this.selectionChange
  21. },
  22. recordSelected: [],
  23. formDialog: false,
  24. formDialogType: 0, // 0:新增, 1:编辑, 2:查看, 3:审核
  25. formDialogTitles: ['新增', '编辑', '查看', '审核'],
  26. pageType: this?.$route?.name,
  27. materialCategoryListL1: [],
  28. materialCategoryListL2: [],
  29. materialNormList: [],
  30. peijianList: [],
  31. websitPurchaseInList: []
  32. }
  33. },
  34. computed: {
  35. // 事件组合
  36. optionsEvensGroup() {
  37. return [
  38. [
  39. [
  40. this.optionsEvensAuth("add", {
  41. click: this.addData
  42. }),
  43. ],
  44. ],
  45. [
  46. [
  47. this.optionsEvensAuth("template", {
  48. isRole: !!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this?.$route?.name),
  49. click: () => {
  50. commonTemplateDownload({ name: '采购入库模板.xlsx' }, `${this.$route.meta.title}`)
  51. .then(res => {
  52. this.$message({
  53. message: '下载成功',
  54. type: 'success'
  55. })
  56. })
  57. .catch(err => {
  58. this.$message.error('下载失败')
  59. })
  60. }
  61. }),
  62. ],
  63. [
  64. this.optionsEvensAuth("imp", ({ moduleName }) => {
  65. return {
  66. isRole: !!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this?.$route?.name),
  67. name: moduleName,
  68. render: () => {
  69. return this.importButton(websitPurchaseInImport, moduleName, { goodsType: this.storageType })
  70. }
  71. }
  72. }),
  73. ],
  74. ],
  75. [
  76. [
  77. this.optionsEvensAuth("template", {
  78. isRole: !!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this?.$route?.name),
  79. click: () => {
  80. commonTemplateDownload({ name: '采购退货模板.xlsx' }, `${this.$route.meta.title}`)
  81. .then(res => {
  82. this.$message({
  83. message: '下载成功',
  84. type: 'success'
  85. })
  86. })
  87. .catch(err => {
  88. this.$message.error('下载失败')
  89. })
  90. }
  91. }),
  92. ],
  93. [
  94. this.optionsEvensAuth("imp", ({ moduleName }) => {
  95. return {
  96. isRole: !!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this?.$route?.name),
  97. name: moduleName,
  98. render: () => {
  99. return this.importButton(websitPurchaseRetImport, moduleName, { goodsType: this.storageType })
  100. }
  101. }
  102. }),
  103. ],
  104. ],
  105. ]
  106. },
  107. moreParameters() {
  108. return [
  109. {
  110. name: '状态',
  111. key: 'flag',
  112. value: '',
  113. conditions: [
  114. {
  115. label: `全部`,
  116. value: ''
  117. },
  118. {
  119. label: `已保存`,
  120. value: "SAVE"
  121. },
  122. {
  123. label: `已审核`,
  124. value: "OK"
  125. }, {
  126. label: `失败`,
  127. value: "FAIL"
  128. },
  129. ]
  130. },
  131. ]
  132. },
  133. columns() {
  134. return [
  135. ...(() => {
  136. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  137. return [{
  138. columnAttributes: {
  139. label: '大类名称',
  140. prop: 'parentCategoryId',
  141. },
  142. render: (h, { row, column, index }) => {
  143. return (
  144. row.isEditRow ?
  145. <div class="redbordererr">
  146. <el-form-item label="" lebel-width="0px" prop={`items.${index}.parentCategoryId`} rules={required}>
  147. <el-select
  148. value={row[column.columnAttributes.prop]}
  149. onInput={(val) => { row[column.columnAttributes.prop] = val }}
  150. onChange={(val) => {
  151. row['goodsCategoryId'] = ""
  152. row['goodsCategoryName'] = ""
  153. row['goodsId'] = ""
  154. row['goodsName'] = ""
  155. this.materialNormList = [];
  156. this.qkrow(row)
  157. if (val) {
  158. row['parentCategoryName'] = this.materialCategoryListL1.find(item => item.categoryId == val).categoryName
  159. } else {
  160. row['parentCategoryName'] = ''
  161. }
  162. this.$nextTick(this.jiaoyan)
  163. }}
  164. placeholder="请选择">
  165. {this.materialCategoryListL1.map((item, index_) => <el-option key={index_} label={item.categoryName} value={item.categoryId}></el-option>)}
  166. </el-select>
  167. </el-form-item>
  168. </div>
  169. :
  170. <div>{row['parentCategoryName']}</div>
  171. )
  172. }
  173. }]
  174. }
  175. return []
  176. })(),
  177. ...(() => {
  178. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  179. return [{
  180. columnAttributes: {
  181. label: '小类名称',
  182. prop: 'goodsCategoryId',
  183. },
  184. render: (h, { row, column, index }) => {
  185. var selectList = row['parentCategoryId'] ? this.materialCategoryListL2.filter(item => item.parentCategoryId == row['parentCategoryId']) : []
  186. return (
  187. row.isEditRow ?
  188. <div class="redbordererr">
  189. <el-form-item label="" lebel-width="0px" prop={`items.${index}.goodsCategoryId`} rules={required}>
  190. <el-select
  191. value={row[column.columnAttributes.prop]}
  192. onInput={(val) => { row[column.columnAttributes.prop] = val }}
  193. placeholder="请选择"
  194. onChange={(val) => {
  195. row['goodsId'] = ""
  196. row['goodsName'] = ""
  197. this.qkrow(row)
  198. if (val) {
  199. row['goodsCategoryName'] = selectList.find(item => item.categoryId == val).categoryName
  200. materialNormList({ isShowStockQty: true, websitId: this.formData.websitId, "pageNum": 1, "pageSize": -1, "params": [{ "param": "b.category_id", "compare": "=", "value": val }, { "param": "a.status", "compare": "=", "value": "ON" }] }).then(res => {
  201. this.materialNormList = res.data.records
  202. })
  203. } else {
  204. this.materialNormList = [];
  205. row['goodsCategoryName'] = ''
  206. }
  207. this.$nextTick(this.jiaoyan)
  208. }}>
  209. {selectList.map((item, index_) => <el-option key={index_} label={item.categoryName} value={item.categoryId}></el-option>)}
  210. </el-select>
  211. </el-form-item>
  212. </div>
  213. :
  214. <div>{row['goodsCategoryName']}</div>
  215. )
  216. }
  217. }]
  218. }
  219. return []
  220. })(),
  221. ...(() => {
  222. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  223. return [{
  224. columnAttributes: {
  225. label: '辅材',
  226. prop: 'goodsId',
  227. },
  228. render: (h, { row, column, index }) => {
  229. return (
  230. row.isEditRow ?
  231. <div class="redbordererr">
  232. <el-form-item label="" lebel-width="0px" prop={`items.${index}.goodsId`} rules={required}>
  233. <el-select
  234. value={row[column.columnAttributes.prop]}
  235. onInput={(val) => { row[column.columnAttributes.prop] = val }}
  236. placeholder="请选择"
  237. onChange={(val) => {
  238. if (val) {
  239. var data = this.materialNormList.find(item => item.goodsId == val)
  240. row['goodsName'] = data.goodsName
  241. this.qkrow(row, {
  242. "goodsStockUnit": data.goodsStockUnit,
  243. "goodsCode": data.goodsCode,
  244. "goodsSpecification": data.goodsSpecification,
  245. "brand": "",
  246. "productCategory": "",
  247. "cost": data.cost,
  248. "costValue": "",
  249. "stockQty": data.stockQty
  250. })
  251. } else {
  252. row['goodsName'] = ''
  253. this.qkrow(row)
  254. }
  255. this.$nextTick(this.jiaoyan)
  256. }}>
  257. {this.materialNormList.filter((item) => !~[...this.formData.items.map(val => val.goodsId).filter(val => val != row.goodsId)].indexOf(item.goodsId)).map((item, index_) => <el-option key={index_} label={item.goodsName} value={item.goodsId}></el-option>)}
  258. </el-select>
  259. </el-form-item>
  260. </div>
  261. :
  262. <div>{row['goodsName']}</div>
  263. )
  264. }
  265. }]
  266. }
  267. return []
  268. })(),
  269. ...(() => {
  270. if (!!~['partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  271. return [{
  272. columnAttributes: {
  273. label: '配件',
  274. prop: 'goodsId',
  275. },
  276. render: (h, { row, column, index }) => {
  277. return (
  278. row.isEditRow ?
  279. <div class="redbordererr">
  280. <el-form-item label="" lebel-width="0px" prop={`items.${index}.goodsId`} rules={required}>
  281. <el-select
  282. value={row[column.columnAttributes.prop]}
  283. onInput={(val) => { row[column.columnAttributes.prop] = val }}
  284. placeholder="请选择"
  285. onChange={(val) => {
  286. this.materialNormList = [];
  287. if (val) {
  288. var data = this.peijianList.find(item => item.goodsId == val)
  289. row['goodsName'] = data.goodsName
  290. this.qkrow(row, {
  291. "goodsStockUnit": data.goodsStockUnit,
  292. "goodsCode": data.goodsCode,
  293. "goodsSpecification": data.goodsSpecification,
  294. "brand": data.brandRelaName,
  295. "productCategory": data.productRelaName,
  296. "cost": data.cost,
  297. "costValue": "",
  298. "stockQty": data.stockQty
  299. })
  300. } else {
  301. row['goodsName'] = ''
  302. this.qkrow(row)
  303. }
  304. this.$nextTick(this.jiaoyan)
  305. }}>
  306. {this.peijianList.filter((item) => !~[...this.formData.items.map(val => val.goodsId).filter(val => val != row.goodsId)].indexOf(item.goodsId)).map((item, index_) => <el-option key={index_} label={item.goodsName} value={item.goodsId}></el-option>)}
  307. </el-select>
  308. </el-form-item>
  309. </div>
  310. :
  311. <div>{row['goodsName']}</div>
  312. )
  313. }
  314. }]
  315. }
  316. return []
  317. })(),
  318. ...(() => {
  319. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  320. return [{
  321. columnAttributes: {
  322. label: '单位',
  323. prop: 'goodsStockUnit',
  324. }
  325. }]
  326. }
  327. return []
  328. })(),
  329. ...(() => {
  330. if (!!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this.pageType)) {
  331. return [{
  332. columnAttributes: {
  333. label: '数量',
  334. prop: 'recQty',
  335. },
  336. render: (h, { row, column, index }) => {
  337. return (
  338. row.isEditRow ?
  339. <div class="redbordererr">
  340. <el-form-item label="" lebel-width="0px" prop={`items.${index}.recQty`} rules={required}>
  341. <el-input
  342. type="number"
  343. value={row[column.columnAttributes.prop]}
  344. onInput={(val) => {
  345. row[column.columnAttributes.prop] = val
  346. if (val) {
  347. row.costValue = this.setNumber(
  348. Number(row.cost) * Number(val)
  349. )
  350. } else {
  351. row.costValue = ""
  352. }
  353. this.$nextTick(this.jiaoyan)
  354. }}
  355. placeholder="请选择">
  356. </el-input>
  357. </el-form-item>
  358. </div>
  359. :
  360. <div>{row[column.columnAttributes.prop]}</div>
  361. )
  362. }
  363. }]
  364. }
  365. return []
  366. })(),
  367. ...(() => {
  368. if (!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.pageType)) {
  369. return [{
  370. columnAttributes: {
  371. label: '退货数量',
  372. prop: 'retQty',
  373. },
  374. render: (h, { row, column, index }) => {
  375. return (
  376. row.isEditRow ?
  377. <div class="redbordererr">
  378. <el-form-item label="" lebel-width="0px" prop={`items.${index}.retQty`} rules={required}>
  379. <el-input
  380. type="number"
  381. value={row[column.columnAttributes.prop]}
  382. onInput={(val) => {
  383. row[column.columnAttributes.prop] = val
  384. if (val) {
  385. row.retValue = this.setNumber(
  386. Number(row.cost) * Number(val)
  387. )
  388. } else {
  389. row.retValue = ""
  390. }
  391. this.$nextTick(this.jiaoyan)
  392. }}
  393. placeholder="请选择">
  394. </el-input>
  395. </el-form-item>
  396. </div>
  397. :
  398. <div>{row[column.columnAttributes.prop]}</div>
  399. )
  400. }
  401. }]
  402. }
  403. return []
  404. })(),
  405. ...(() => {
  406. if (!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.pageType)) {
  407. return [{
  408. columnAttributes: {
  409. label: '退款金额',
  410. prop: 'retValue',
  411. }
  412. }]
  413. }
  414. return []
  415. })(),
  416. ...(() => {
  417. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  418. return [{
  419. columnAttributes: {
  420. label: '商品代码',
  421. prop: 'goodsCode',
  422. }
  423. }]
  424. }
  425. return []
  426. })(),
  427. ...(() => {
  428. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  429. return [{
  430. columnAttributes: {
  431. label: '规格型号',
  432. prop: 'goodsSpecification',
  433. }
  434. }]
  435. }
  436. return []
  437. })(),
  438. ...(() => {
  439. if (!!~['partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  440. return [{
  441. columnAttributes: {
  442. label: '配件编码',
  443. prop: 'goodsId',
  444. }
  445. }]
  446. }
  447. return []
  448. })(),
  449. ...(() => {
  450. if (!!~['partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  451. return [{
  452. columnAttributes: {
  453. label: '适用品牌',
  454. prop: 'brand',
  455. }
  456. }]
  457. }
  458. return []
  459. })(),
  460. ...(() => {
  461. if (!!~['partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  462. return [{
  463. columnAttributes: {
  464. label: '适用产品大类',
  465. prop: 'productCategory',
  466. }
  467. }]
  468. }
  469. return []
  470. })(),
  471. ...(() => {
  472. if (!!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.pageType)) {
  473. return [{
  474. columnAttributes: {
  475. label: '采购数量',
  476. prop: 'recQty',
  477. }
  478. }]
  479. }
  480. return []
  481. })(),
  482. ...(() => {
  483. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  484. return [{
  485. columnAttributes: {
  486. label: '采购价格',
  487. prop: 'cost',
  488. }
  489. }]
  490. }
  491. return []
  492. })(),
  493. ...(() => {
  494. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  495. return [{
  496. columnAttributes: {
  497. label: '采购金额',
  498. prop: 'costValue',
  499. }
  500. }]
  501. }
  502. return []
  503. })(),
  504. ...(() => {
  505. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials', 'partsStorage', 'partsReturn'].indexOf(this.pageType) && this.formData.flag !== "OK") {
  506. return [{
  507. columnAttributes: {
  508. label: '库存数量',
  509. prop: 'stockQty',
  510. }
  511. }]
  512. }
  513. return []
  514. })(),
  515. ...(() => {
  516. if (!!~[0, 1].indexOf(this.formDialogType)) {
  517. return [{
  518. columnAttributes: {
  519. label: '操作',
  520. prop: '',
  521. },
  522. render: (h, { row, column, index }) => {
  523. return (
  524. <div class='operation-btns'>
  525. <el-button type="text" onClick={() => {
  526. this.formData.items.splice(index, 1)
  527. }}>删除</el-button>
  528. {
  529. row.isEditRow ?
  530. <el-button type="text" onClick={() => {
  531. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  532. if (valid) {
  533. this.formData.items[index].isEditRow = false
  534. }
  535. })
  536. }}>确定</el-button> :
  537. null
  538. }
  539. {
  540. !row.isEditRow ?
  541. <el-button type="text" onClick={() => {
  542. this.formData.items.map((item, index_) => {
  543. if (index_ == index) {
  544. item.isEditRow = true
  545. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType) && row.goodsCategoryId) {
  546. materialNormList({ isShowStockQty: true, websitId: this.formData.websitId, "pageNum": 1, "pageSize": -1, "params": [{ "param": "b.category_id", "compare": "=", "value": row.goodsCategoryId }, { "param": "a.status", "compare": "=", "value": "ON" }] }).then(res => {
  547. this.materialNormList = res.data.records
  548. })
  549. }
  550. } else {
  551. item.isEditRow = false
  552. }
  553. })
  554. }}>编辑</el-button> :
  555. null
  556. }
  557. </div>
  558. )
  559. }
  560. }]
  561. }
  562. return []
  563. })(),
  564. ]
  565. },
  566. formItems1() {
  567. return [
  568. {
  569. md: 24,
  570. isShow: true,
  571. name: 'slot-component',
  572. formItemAttributes: {
  573. label: '',
  574. prop: '',
  575. 'label-width': '0px'
  576. },
  577. render: (h, { props, onInput }) => {
  578. var { value } = props
  579. return (
  580. <div>
  581. <el-descriptions border title="" column={4} colon={false} labelStyle={{ width: '8%' }} contentStyle={{ width: '17%' }}>
  582. <el-descriptions-item label="单据状态">
  583. {({ SAVE: "保存", OK: "通过", FAIL: "失败" })[this.formData.flag]}
  584. </el-descriptions-item>
  585. <el-descriptions-item label="单据编号">
  586. {(!!~['auxiliaryMaterialsStorage', 'partsStorage'].indexOf(this.pageType) ? this.formData.purchaseId : this.formData.purchaseRetId) || ''}
  587. </el-descriptions-item>
  588. <el-descriptions-item label="所属商户" contentStyle={{ width: '42%' }}>
  589. {this.formData.companyWechatName}
  590. </el-descriptions-item>
  591. </el-descriptions>
  592. <el-descriptions border title="" column={2} colon={false} labelStyle={{ width: '8%' }} contentStyle={{ width: '42%' }} style="margin-top:-1px">
  593. <el-descriptions-item label="网点名称">
  594. <div class="redbordererr">
  595. <el-form-item label="" lebel-width="0px" prop={`websitId`} rules={required}>
  596. <el-select
  597. style="width:100%"
  598. value={this.formData.websitId} onInput={(val) => { this.formData.websitId = val }}
  599. placeholder="请选择"
  600. disabled={this.formDialogType >= 2}
  601. onChange={(val) => {
  602. this.formData.items = []
  603. if (val) {
  604. this.formData['websitName'] = this.getWebsitList.find(item => item.websitId == val).name
  605. } else {
  606. this.formData['websitName'] = ''
  607. }
  608. if (~['partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  609. if (val) {
  610. peijianList({ isShowStockQty: true, websitId: val, "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.status", "compare": "=", "value": "ON" }, { "param": "a.norm_type", "compare": "=", "value": "M" }] }).then((res) => {
  611. this.peijianList = res.data.records
  612. })
  613. } else {
  614. this.peijianList = []
  615. }
  616. }
  617. this.getorderlist()
  618. this.$nextTick(this.jiaoyan)
  619. }}>
  620. {this.getWebsitList.map(item => <el-option key={item.websitId} label={item.name} value={item.websitId}></el-option>)}
  621. </el-select>
  622. </el-form-item>
  623. </div>
  624. </el-descriptions-item>
  625. <el-descriptions-item label="供应商名称">
  626. <div class="redbordererr">
  627. <el-form-item label="" lebel-width="0px" prop={`venderId`} rules={required}>
  628. <el-select
  629. style="width:100%"
  630. value={this.formData.venderId}
  631. onInput={(val) => { this.formData.venderId = val }}
  632. placeholder="请选择"
  633. disabled={this.formDialogType >= 2}
  634. onChange={(val) => {
  635. if (val) {
  636. this.formData['venderName'] = this.listPageV2Data.find(item => item.venderId == val).venderName
  637. } else {
  638. this.formData['venderName'] = ''
  639. }
  640. this.getorderlist()
  641. this.$nextTick(this.jiaoyan)
  642. }}>
  643. {this.listPageV2Data.map(item => <el-option key={item.venderId} label={item.venderName} value={item.venderId}></el-option>)}
  644. </el-select>
  645. </el-form-item>
  646. </div>
  647. </el-descriptions-item>
  648. </el-descriptions>
  649. {
  650. !!~['returnAuxiliaryMaterials', 'partsReturn'].indexOf(this.pageType) ?
  651. <el-descriptions border title="" column={4} colon={false} labelStyle={{ width: '8%' }} contentStyle={{ width: '17%' }} style="margin-top:-1px">
  652. <el-descriptions-item label="采购入库单号" contentStyle={{ width: '42%' }}>
  653. <div class="redbordererr">
  654. <el-form-item label="" lebel-width="0px" prop={`purchaseId`}>
  655. <zj-select
  656. style="width:100%"
  657. value={this.formData.purchaseId}
  658. onInput={(val) => { this.formData.purchaseId = val }}
  659. placeholder="请选择"
  660. disabled={this.formDialogType >= 2}
  661. clearable={true}
  662. filterable={true}
  663. blurNoMatchText={true}
  664. blurNoMatchInputBorderColor=""
  665. onChange={(val) => {
  666. if (val) {
  667. var data = this.websitPurchaseInList.find(item => item.purchaseId == val)
  668. if (data) {
  669. websitPurchaseInDetail({ purchaseId: data.purchaseId }).then(res => {
  670. Object.assign(this.formData, {
  671. items: res.data.items.map((item, index) => ({
  672. ...item,
  673. retQty: "",
  674. retValue: "",
  675. isEditRow: !index
  676. }))
  677. })
  678. var row = this.formData.items[0]
  679. if (!!~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType) && row && row.goodsCategoryId) {
  680. materialNormList({ isShowStockQty: true, websitId: this.formData.websitId, "pageNum": 1, "pageSize": -1, "params": [{ "param": "b.category_id", "compare": "=", "value": row.goodsCategoryId }, { "param": "a.status", "compare": "=", "value": "ON" }] }).then(res => {
  681. this.materialNormList = res.data.records
  682. })
  683. }
  684. })
  685. return
  686. }
  687. }
  688. this.formData.items = []
  689. this.$nextTick(this.jiaoyan)
  690. }}>
  691. {this.websitPurchaseInList.map(item => <zj-option key={item.purchaseId} label={item.showLabel} value={item.purchaseId}></zj-option>)}
  692. </zj-select>
  693. </el-form-item>
  694. </div>
  695. </el-descriptions-item>
  696. <el-descriptions-item label="退货数量">
  697. {!~[0, 1].indexOf(this.formDialogType) ? this.formData.retTotalQty : this.setNumber([0, 0, 0, ...this.formData.items.map(row => {
  698. return Number(row.retQty)
  699. })].reduce((a, b) => a + b))}
  700. </el-descriptions-item>
  701. <el-descriptions-item label="退款金额">
  702. {!~[0, 1].indexOf(this.formDialogType) ? this.formData.retTotalAmount : this.setNumber([0, 0, 0, ...this.formData.items.map(row => {
  703. return Number(row.cost) * Number(row.retQty)
  704. })].reduce((a, b) => a + b))}
  705. </el-descriptions-item>
  706. </el-descriptions> : null
  707. }
  708. <el-descriptions border title="" column={4} colon={false} labelStyle={{ width: '8%' }} contentStyle={{ width: '17%' }} style="margin-top:-1px">
  709. <el-descriptions-item label="制单人">
  710. {this.formData.createBy}
  711. </el-descriptions-item>
  712. <el-descriptions-item label="制单时间">
  713. {this.formData.createTime}
  714. </el-descriptions-item>
  715. <el-descriptions-item label="审核人">
  716. {this.formData.confirmBy}
  717. </el-descriptions-item>
  718. <el-descriptions-item label="审核时间">
  719. {this.formData.confirmTime}
  720. </el-descriptions-item>
  721. </el-descriptions>
  722. <el-descriptions border title="" column={4} colon={false} labelStyle={{ width: '8%' }} contentStyle={{ width: '17%' }} style="margin-top:-1px">
  723. <el-descriptions-item label="附件">
  724. <ImageUpload fileList={this.formData.imageUrl} uid="imgSrc666_materials_drawing_images" limit={1} isEdit={this.formDialogType < 2} />
  725. </el-descriptions-item>
  726. <el-descriptions-item label="备注" contentStyle={{ width: '67%' }}>
  727. <el-input
  728. type="textarea"
  729. placeholder="请输入内容"
  730. value={this.formData.remark}
  731. onInput={(val) => { this.formData.remark = val }}
  732. maxlength="200"
  733. show-word-limit
  734. autosize={{ minRows: 6, maxRows: 8 }}
  735. disabled={this.formDialogType >= 2}
  736. >
  737. </el-input>
  738. </el-descriptions-item>
  739. </el-descriptions>
  740. </div>
  741. )
  742. }
  743. },]
  744. },
  745. formItems2() {
  746. return [
  747. {
  748. md: 24,
  749. isShow: true,
  750. name: 'slot-component',
  751. formItemAttributes: {
  752. label: '',
  753. prop: 'items',
  754. 'label-width': '0px',
  755. rules: [...required]
  756. },
  757. render: (h, { props, onInput }) => {
  758. var { value } = props
  759. return (
  760. <div>
  761. {!!~[0, 1].indexOf(this.formDialogType) ? <div style="margin-bottom:8px">
  762. <el-button onClick={() => {
  763. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  764. if (valid || (Object.keys(invalidFields).length == 1 && invalidFields.items)) {
  765. this.formData.items.map((item) => { item.isEditRow = false })
  766. this.formData.items.push({
  767. "brand": "",
  768. "companyWechatId": "",
  769. "cost": "",
  770. "costValue": "",
  771. "goodsCategoryId": "",
  772. "goodsCategoryName": "",
  773. "goodsCode": "",
  774. "goodsId": "",
  775. "goodsName": "",
  776. "goodsSpecification": "",
  777. "goodsStockUnit": "",
  778. "goodsType": "",
  779. "note": "",
  780. "parentCategoryId": "",
  781. "parentCategoryName": "",
  782. "productCategory": "",
  783. "purchaseId": "",
  784. "recQty": "",
  785. "retQty": "",
  786. "retValue": "",
  787. "stockQty": "",
  788. "websitId": "",
  789. "websitName": "",
  790. "isEditRow": true,
  791. })
  792. }
  793. })
  794. }}>添加</el-button>
  795. </div> : null}
  796. <zj-table
  797. columns={this.columns}
  798. tableData={this.formData.items}
  799. tableAttributes={{
  800. size: 'mini',
  801. border: true,
  802. }} />
  803. </div>
  804. )
  805. }
  806. },]
  807. }
  808. },
  809. methods: {
  810. // 表格列解析渲染数据更改
  811. columnParsing(item, defaultData) {
  812. if (item.jname === 'imageUrl') {
  813. defaultData.render = (h, { row, index, column }) => {
  814. return (
  815. <div style="padding:0 6px;cursor: pointer;">
  816. {row.imageUrl ? row.imageUrl.split(",").map(url => <el-image src={url} preview-src-list={[url]} fit="fit" style="width:80px;height:80px;" />) : null}
  817. </div>
  818. )
  819. }
  820. }
  821. return defaultData
  822. },
  823. // 监听勾选变化
  824. selectionChange(data) {
  825. this.recordSelected = data
  826. },
  827. // 打开
  828. openForm() {
  829. this.getorderlist(false)
  830. var req = [
  831. getWebsit({ type: "C", status: true }),
  832. ]
  833. var runs = [
  834. (res) => { this.getWebsitList = res.data.filter(item => item.type == "C") },
  835. ]
  836. if (~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  837. req.push(...[
  838. listPageV2({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.status", "compare": "=", "value": "ON" }, { "param": "a.vender_type", "compare": "=", "value": ["A", "M"] }] })
  839. ])
  840. runs.push(...[
  841. (res) => { this.listPageV2Data = res.data.records }
  842. ])
  843. } else if (~['partsStorage', 'partsReturn'].indexOf(this.pageType)) {
  844. req.push(...[
  845. listPageV2({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.status", "compare": "=", "value": "ON" }, { "param": "a.vender_type", "compare": "=", "value": ["P", "A"] }] })
  846. ])
  847. runs.push(...[
  848. (res) => { this.listPageV2Data = res.data.records }
  849. ])
  850. }
  851. if (~['auxiliaryMaterialsStorage', 'returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  852. req.push(...[
  853. materialCategoryList({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.status", "compare": "=", "value": "ON" }, { "param": "a.category_level", "compare": "=", "value": "1" }] }),
  854. materialCategoryList({ "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.status", "compare": "=", "value": "ON" }, { "param": "a.category_level", "compare": "=", "value": "2" }] }),
  855. ])
  856. runs.push(...[
  857. (res) => { this.materialCategoryListL1 = res.data.records },
  858. (res) => { this.materialCategoryListL2 = res.data.records }
  859. ])
  860. } else if (~['partsStorage', 'partsReturn'].indexOf(this.pageType) && this.formData.websitId) {
  861. req.push(...[
  862. peijianList({ isShowStockQty: true, websitId: this.formData.websitId, "pageNum": 1, "pageSize": -1, "params": [{ "param": "a.status", "compare": "=", "value": "ON" }, { "param": "a.norm_type", "compare": "=", "value": "M" }] })
  863. ])
  864. runs.push(...[
  865. (res) => { this.peijianList = res.data.records },
  866. ])
  867. }
  868. Promise.all(req).then((ress) => {
  869. ress.forEach((res, index) => {
  870. runs[index](res)
  871. })
  872. this.formDialog = true
  873. })
  874. },
  875. qkrow(row, data = {}) {
  876. ["goodsStockUnit", "recQty", "retQty", "retValue", "goodsCode", "goodsSpecification", "brand", "productCategory", "cost", "costValue", "stockQty"].map(key => {
  877. if (row[key] !== undefined) {
  878. row[key] = data[key] !== undefined ? data[key] : ""
  879. }
  880. })
  881. },
  882. getorderlist(bool = true) {
  883. if (this.formData.websitId && this.formData.venderId) {
  884. if (~['returnAuxiliaryMaterials'].indexOf(this.pageType)) {
  885. if (bool) {
  886. this.websitPurchaseInList = []
  887. this.formData.items = []
  888. this.formData.purchaseId = ""
  889. }
  890. websitPurchaseInList({
  891. "pageNum": 1,
  892. "pageSize": -1,
  893. "params": [
  894. { "param": "a.goods_type", "compare": "=", "value": "M" },
  895. { "param": "a.flag", "compare": "=", "value": "OK" },
  896. { "param": "a.websit_id", "compare": "=", "value": this.formData.websitId },
  897. { "param": "a.vender_id", "compare": "=", "value": this.formData.venderId },
  898. ]
  899. }).then(res => {
  900. this.websitPurchaseInList = res.data.records.map(item => ({
  901. ...item,
  902. showLabel: `单号:${item.purchaseId} / 金额:${item.totalAmount} / 时间:${item.createTime.split(" ")[0]}`
  903. }))
  904. })
  905. } else if (~['partsReturn'].indexOf(this.pageType)) {
  906. if (bool) {
  907. this.websitPurchaseInList = []
  908. this.formData.items = []
  909. this.formData.purchaseId = ""
  910. }
  911. websitPurchaseInList({
  912. "pageNum": 1,
  913. "pageSize": -1,
  914. "params": [
  915. { "param": "a.goods_type", "compare": "=", "value": "P" },
  916. { "param": "a.flag", "compare": "=", "value": "OK" },
  917. { "param": "a.websit_id", "compare": "=", "value": this.formData.websitId },
  918. { "param": "a.vender_id", "compare": "=", "value": this.formData.venderId },
  919. ]
  920. }).then(res => {
  921. this.websitPurchaseInList = res.data.records.map(item => ({
  922. ...item,
  923. showLabel: `单号:${item.purchaseId} / 金额:${item.totalAmount} / 时间:${item.createTime.split(" ")[0]}`
  924. }))
  925. })
  926. }
  927. }
  928. },
  929. // 添加
  930. addData() {
  931. this.formDialogType = 0
  932. this.openForm()
  933. },
  934. // 关闭弹窗
  935. formCancel() {
  936. this.$refs.formRef.$refs.inlineForm.clearValidate()
  937. this.$data.formData = this.$options.data().formData
  938. this.formDialog = false
  939. },
  940. jiaoyan() {
  941. this.$refs.formRef.validate((valid, invalidFields, errLabels) => { }, false)
  942. },
  943. setNumber(val) {
  944. return Number(val.toFixed(2))
  945. }
  946. },
  947. }