index.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
  1. <script>
  2. import orderApi from "@/api/business/purchase/purchase-order";
  3. import { initColumns, initDicts, initRules, initParams } from "@/utils/init/index.js";
  4. // import { Columns, TabColumns } from "./column";
  5. import judgeColumns from "./column";
  6. import { tax, currency } from "@/components/popover-select-v2/fetch";
  7. const {Columns,TabColumns} = judgeColumns();
  8. const NewColumns = initColumns(Columns);
  9. const NewTabColumns = TabColumns.map((element) => ({
  10. ...element,
  11. tableColumns: initColumns(element.tableColumns),
  12. }));
  13. const SelectColumns = NewColumns.filter(
  14. (column) => column.inputType === "Select"
  15. );
  16. NewTabColumns.forEach((column) => {
  17. SelectColumns.push(
  18. ...column.tableColumns.filter((cColumn) => cColumn.inputType === "Select")
  19. );
  20. });
  21. export default {
  22. name: "AddPurchaseOrderDrawer",
  23. props:{
  24. // roles:{
  25. // type:[Array,String,Object],
  26. // require:true,
  27. // }
  28. },
  29. dicts: initDicts(SelectColumns),
  30. components: {
  31. FileUploadCenter: () => import("../components/FileUploadCenter/index.vue"),
  32. popDialog: () => import("@/components/PopDialog/index.vue"),
  33. BatchImport: () => import("@/components/BatchImport/index.vue"),
  34. },
  35. data() {
  36. return {
  37. visible: false,
  38. loading:false,
  39. tabLoading:false,
  40. columns: NewColumns,
  41. rules: initRules(NewColumns),
  42. count:0,
  43. params: {
  44. ...initParams(NewColumns),
  45. puOrderItemList: [],
  46. puOrderExecuteList: [],
  47. },
  48. tabColumns: NewTabColumns,
  49. tabName: "puOrderItemList",
  50. isCopy:false,
  51. };
  52. },
  53. computed: {
  54. role:{
  55. get(){
  56. let {roles} = this.$store.state.user;
  57. return roles.find(item => item === "syfz-purchaseorder") || "procurementManager";
  58. },
  59. set(){}
  60. }
  61. },
  62. watch: {
  63. "params.puOrderItemList": {
  64. handler(nVal, oVal) {
  65. this.visible &&
  66. this.handleSynchronousMaterial(
  67. "puOrderItemList",
  68. "puOrderExecuteList"
  69. );
  70. },
  71. deep: true,
  72. },
  73. "params.puOrderExecuteList": {
  74. handler(nVal, oVal) {
  75. this.visible &&
  76. this.handleSynchronousMaterial(
  77. "puOrderExecuteList",
  78. "puOrderItemList"
  79. );
  80. },
  81. deep: true,
  82. },
  83. "params.billType":{
  84. handler(nVal, oVal){
  85. let billList = ['21-Cxx-02','21-Cxx-04','21-Cxx-10','21-Cxx-14','21-Cxx-09','21-Cxx-17','21-Cxx-18'];
  86. if(billList.find(item => item === nVal)){
  87. this.rules.warehouseName = [
  88. { required: true, message: "WMS入库仓库不能为空", trigger: "change" },
  89. ];
  90. }else{
  91. this.rules.warehouseName = null;
  92. }
  93. this.count++;
  94. }
  95. }
  96. },
  97. methods: {
  98. beforeOpen() {
  99. if(!this.isCopy){
  100. const { deptName, deptId, name, nickName, orgName, orgId } = this.$store.state.user;
  101. this.params.puOrg = orgId;
  102. this.params.puOrgName = orgName;
  103. this.params.buyer = name;
  104. this.params.buyerName = nickName;
  105. this.params.puDept = deptId;
  106. this.params.puDeptName = deptName;
  107. this.params.billDate = new Date().Format('yyyy-MM-dd');
  108. this.params.createTime = new Date().Format('yyyy-MM-dd HH:mm:ss');
  109. console.log(this.params,'this.params');
  110. // this.addTableRow();
  111. }
  112. },
  113. setVisible(prop,iscopy) {
  114. this.visible = prop;
  115. this.isCopy = iscopy;
  116. if(!this.visible){
  117. this.$refs['orderAddForm'].clearValidate();
  118. }
  119. },
  120. // 复制赋值
  121. async setCopyParams(id) {
  122. try {
  123. this.loading = true;
  124. const { code, msg, data } = await orderApi.details(id);
  125. if (code === 200) {
  126. this.params = {
  127. ...data,
  128. id: "",
  129. code: "",
  130. isEnd:'N',
  131. status: "0",
  132. source: "3",
  133. isClose:'N',
  134. billDate: new Date().Format('yyyy-MM-dd'),
  135. createTime : new Date().Format('yyyy-MM-dd HH:mm:ss'),
  136. closeTime:'',
  137. oaDemandNo:'',
  138. isInvoice:'N',
  139. isSendWms:'N',
  140. rebateMoney:'',
  141. invoiceMoney:'',
  142. paymentMoney:'',
  143. applyPaymentMoney:'',
  144. erpOrderCode:'',
  145. };
  146. try {
  147. const { code, rows} = await orderApi.REFER(
  148. {
  149. type:'WAREHOUSE_PARAM',
  150. search: this.params.warehouseName,
  151. isPage: true,
  152. }, {pageNum: 1 , pageSize: 10} );
  153. if(code ==200){
  154. this.judgeGoodsAllocation(rows[0].csFlag);
  155. }
  156. } catch (error) {
  157. }
  158. for (const key in this.params) {
  159. // if (Array.isArray(this.params[key])) {
  160. if (key === 'puOrderItemList' || key === 'puOrderExecuteList') {
  161. this.params[key].forEach((v) => {
  162. v.id = "";
  163. v.demandCode = "";
  164. v['isInvoice'] && (v['isInvoice'] = 'N');
  165. v['isStorage'] && (v['isStorage'] = 'N');
  166. v['isArrival'] && (v['isArrival'] = 'N');
  167. v['isPayment'] && (v['isPayment'] = 'N');
  168. });
  169. }
  170. }
  171. // 清空 累计本币开票金额、
  172. // 累计付款金额、累计付款申请金额、累计开票主数量、最终关闭时间
  173. // 、最终关闭、已同步WMS 、订单抵扣余额金额、订单使用返利金额、 发票标识
  174. }
  175. } catch (err) {
  176. //
  177. } finally {
  178. this.loading = false;
  179. }
  180. },
  181. // 增行
  182. addTableRow(prop) {
  183. for (const key in this.params) {
  184. // if (Array.isArray(this.params[key])) {
  185. if (key === 'puOrderItemList' || key === 'puOrderExecuteList') {
  186. const arr = this.tabColumns.find(
  187. (element) => element.key === key
  188. ).tableColumns;
  189. let rowData = initParams(arr, "key", "value");
  190. "rowno" in rowData &&
  191. (rowData["rowno"] = this.params[key].length + 1);
  192. // 物料
  193. if("rowNo" in rowData){
  194. rowData["rowNo"] = this.params[key].length + 1;
  195. // 扣税类别
  196. rowData["taxDeductClassify"] = '1';
  197. // 折本汇率
  198. rowData["exchangeRate"] = '1';
  199. // 价格类型
  200. rowData["priceType"] = 'order';
  201. // 币种
  202. rowData["currency"] = '1002Z0100000000001K1';
  203. rowData["currencyName"] = '人民币';
  204. }
  205. // 是否完成询价,新增明细行需默认明细为false
  206. // rowData["whetherCompleteInquiry"] = false;
  207. this.params[key].push(rowData);
  208. }
  209. }
  210. // const arr = this.tabColumns.find(
  211. // (element) => element.key === this.tabName
  212. // ).tableColumns;
  213. // prop.push(initParams(arr, "key", "value"));
  214. },
  215. // 删行
  216. async delTableRow(prop, index) {
  217. for (const key in this.params) {
  218. // if (Array.isArray(this.params[key])) {
  219. if (key === 'puOrderItemList' || key === 'puOrderExecuteList') {
  220. this.params[key].splice(index, 1);
  221. }
  222. }
  223. await this.handleGetPrice();
  224. // prop.splice(index, 1);
  225. },
  226. // 同步子表物料
  227. handleSynchronousMaterial(tableOne, tableTwo) {
  228. let _this = this;
  229. // this.params[tableOne]-- -> this.params[tableTwo]
  230. this.params[tableOne] &&
  231. this.params[tableOne].forEach((item, index) => {
  232. for (const key in item) {
  233. if(!_this.params[tableTwo][index]){
  234. const arr = _this.tabColumns.find(
  235. (element) => element.key === tableTwo
  236. ).tableColumns;
  237. _this.params[tableTwo].push(initParams(arr, "key", "value"));
  238. }
  239. if (key in _this.params[tableTwo][index]) {
  240. _this.params[tableTwo][index].material = item.material;
  241. key !== 'id' && ( _this.params[tableTwo][index][key] = item[key]);
  242. }
  243. }
  244. });
  245. },
  246. // 取消
  247. handleCancel() {
  248. this.params = {
  249. ...initParams(this.columns),
  250. puOrderItemList: [],
  251. puOrderExecuteList: [],
  252. };
  253. this.setVisible(false);
  254. },
  255. // 判断保存条件
  256. judgeSaveCondition(cb){
  257. this.$refs['orderAddForm'].validate(async (valid) => {
  258. if (valid) {
  259. if(!this.params['puOrderItemList'].length || !this.params['puOrderExecuteList'].length){
  260. this.$notify.error({
  261. title: '错误',
  262. message: '请填写订单行!'
  263. });
  264. return false;
  265. }
  266. // puOrderItemList
  267. // let isPrice = this.params.puOrderItemList.filter(item => !item.whetherCompleteInquiry);
  268. // if(isPrice.length && this.role === 'procurementManager'){
  269. // this.$notify.error({
  270. // title: '错误',
  271. // message: '询价失败!'
  272. // });
  273. // return false
  274. // }
  275. // console.log(isPrice,'isPrice');
  276. cb();
  277. } else {
  278. this.$notify.error({
  279. title: '错误',
  280. message: '存在必填项未填写'
  281. });
  282. console.log('error submit!!');
  283. return false;
  284. }
  285. });
  286. },
  287. // 保存
  288. handleSava() {
  289. console.log(this.params,'this.params---------');
  290. this.judgeSaveCondition(async()=>{
  291. try {
  292. this.loading = true;
  293. const { code, msg } = await orderApi.create(this.params);
  294. if (code === 200) {
  295. this.handleCancel();
  296. }
  297. } catch (err) {
  298. //
  299. } finally {
  300. this.loading = false;
  301. }
  302. })
  303. },
  304. judgeGoodsAllocation(porp){
  305. if(porp === 'Y'){
  306. this.rules.goodsAllocationName = [
  307. { required: true, message: "货位不能为空", trigger: "change" },
  308. ];
  309. } else{
  310. this.rules.goodsAllocationName = null;
  311. }
  312. this.count++;
  313. },
  314. // 主表参照改变之后
  315. async handleReferChange(val, type, source){
  316. let page = { pageNum: 1 , pageSize: 10 };
  317. // 供应商选择
  318. if( type === 'SUPPLIER_PARAM' ){
  319. let relevanceRefer = [
  320. {
  321. // 供应商联系人
  322. key:'supplierContacts',
  323. params:{
  324. type:'SUPPLIERCONTACTS_PARAM',
  325. supplierId:val.id,
  326. }
  327. },
  328. {
  329. // 供应商业务员
  330. key:'supplierPersonal',
  331. params:{
  332. type:'PSNLICENSE_PARAM',
  333. supplierId:val.id,
  334. pkOrg: source.puOrg,
  335. }
  336. }
  337. ]
  338. await relevanceRefer.forEach(async (refer) =>{
  339. try {
  340. const { code, rows} = await orderApi.REFER(
  341. {
  342. ...refer.params,
  343. search: "",
  344. isPage: true,
  345. }, page );
  346. if (code === 200) {
  347. source[refer.key] = rows[0]? rows[0].id :'';
  348. source[`${refer.key}Name`] = rows[0] ? rows[0].name :'';
  349. }
  350. } catch (error) {}
  351. })
  352. // 明细不为空的情况下进行询价
  353. let detailList = this.params['puOrderItemList'].filter(item => (
  354. item.material && item.material != ''
  355. ))
  356. if(detailList.length){
  357. // this.params['puOrderItemList'] = this.params['puOrderItemList'].map(item => {
  358. // item['whetherCompleteInquiry'] = false
  359. // return item;
  360. // });
  361. await this.handleGetPrice();
  362. }
  363. }
  364. // 组织
  365. if(type === 'ORG_PARAM'){
  366. for (const key in this.params) {
  367. // if (Array.isArray(this.params[key])) {
  368. if (key === 'puOrderItemList' || key === 'puOrderExecuteList') {
  369. this.params[key] = [];
  370. }
  371. else if(key === 'sysFileRecordList'){
  372. this.params[key] = [];
  373. }
  374. else if (
  375. key != "puOrg" &&
  376. key != "puOrgName" &&
  377. key != "buyer" &&
  378. key != "buyerName" &&
  379. key != "puDept" &&
  380. key != "puDeptName" &&
  381. key != "status" &&
  382. key != "billDate" &&
  383. key != "createTime"
  384. ) {
  385. this.params[key] = "";
  386. } else {
  387. }
  388. }
  389. }
  390. // WMS仓库
  391. if(type === 'WAREHOUSE_PARAM'){
  392. this.judgeGoodsAllocation(val.csFlag);
  393. source.goodsAllocation = ''
  394. source.goodsAllocationName = ''
  395. // this.count++
  396. }
  397. },
  398. // 下拉框选择改变
  399. handleSelectChange(val,typeName){
  400. if(val === 'billType'){
  401. this.params['billTypeName'] = this.dict.type[typeName].find(item => item.value == this.params[val]).label;
  402. }
  403. },
  404. // 子表参照改变之后
  405. async handleTabReferChange(val, type, source) {
  406. // 触发物料参照询价
  407. if (type == "MATERIAL_PARAM" && source.qty && source.qty != "") {
  408. source['qty'] = 0;
  409. // source['whetherCompleteInquiry'] = false;
  410. source['taxPrice'] = 0;
  411. source['money'] = 0;
  412. source['taxDeductMoneya'] = 0;
  413. source['price'] = 0;
  414. source['notaxMoney'] = 0;
  415. source['tax'] = 0;
  416. this.params['qty'] = 0;
  417. this.params['originalQty'] = 0;
  418. this.params['money'] = 0;
  419. this.params['originalMoney'] = 0;
  420. this.params['notaxMoney'] = 0;
  421. source.isDrug = val.materialMedcine.isDrug == '0' ? 'Y' : 'N';
  422. // await this.handleGetPrice();
  423. }
  424. // 物料触发税率
  425. if( type == "MATERIAL_PARAM"){
  426. let {rateCode} = source;
  427. try {
  428. // try
  429. this.loading = true;
  430. const { ntaxrate } = await tax(rateCode);
  431. source.tax = ntaxrate === "0E-8" ? 0 : ntaxrate;
  432. } catch (err) {
  433. // catch
  434. console.error(err);
  435. } finally {
  436. // finally
  437. this.loading = false;
  438. }
  439. }
  440. },
  441. // 子表下拉框改变
  442. async handleTabSelectChange(type,row){
  443. if(type == 'priceType' && row.material && row.qty && row.qty != ""){
  444. // row['whetherCompleteInquiry'] = false;
  445. await this.handleGetPrice();
  446. }
  447. },
  448. // 子表inputNumber
  449. handleInputChange(row, type) {
  450. // 物料数量变化----询价
  451. if ((type == "qty" || type == "taxPrice" || type == 'taxDeductMoneya')&& row.material) {
  452. // row['whetherCompleteInquiry'] = false;
  453. this.handleGetPrice();
  454. }
  455. // if(this.role === 'syfz-purchaseorder' && row.material && (type == "qty" ||type === "taxPrice" )){
  456. // row.money = row.qty * row.taxPrice;
  457. // }
  458. },
  459. // 子表多选框改变
  460. handleTabCheckbox(type,source){
  461. // 勾选赠品,价税合计更新为0,含税单价、无税单价更新为0
  462. if(type === 'isGift' && source.material && source.qty && source.qty != ""){
  463. // source['whetherCompleteInquiry'] = false;
  464. this.handleGetPrice()
  465. }
  466. },
  467. // 询价 getPrice
  468. async handleGetPrice() {
  469. try {
  470. // action:insert(新增)、revise(修订)、update(编辑)
  471. let { code, data } = await orderApi.getPrice({ ...this.params,action: 'insert' });
  472. if (code == 200) {
  473. this.params = data;
  474. }
  475. } catch (error) {}
  476. },
  477. async handelImport(fileList){
  478. try {
  479. let formData = new FormData();
  480. formData.append('file',fileList[0].raw);
  481. this.$modal.loading("正在上传文件,请稍候...");
  482. let {code,data} = await orderApi.orderImport(formData);
  483. if(code == 200) {
  484. this.tabLoading = true;
  485. // puOrderExecuteList puOrderItemList
  486. let size = 20;
  487. let num = 1;
  488. let total = Math.ceil(data['puOrderItemList'].length / size);
  489. let resultData = {...data};
  490. let intervalPush = setInterval(()=>{
  491. if(num > total){
  492. clearInterval(intervalPush);
  493. this.tabLoading = false;
  494. this.handleGetPrice();
  495. }
  496. for (const key in resultData) {
  497. resultData[key].slice(size*(num-1), (size*num) ).forEach(item =>{
  498. this.params[key].push(item);
  499. })
  500. }
  501. num++;
  502. },200);
  503. // for (const key in data) {
  504. // this.params[key].push(...data[key]);
  505. // }
  506. let {setVisible} = this.$refs.batchImport;
  507. setVisible(false);
  508. }
  509. } catch (error) {
  510. }finally{
  511. this.$modal.closeLoading();
  512. }
  513. },
  514. async handleTemDownload(){
  515. this.download('/pu/order/downloadFailData',{}, `采购订单物料信息模板${new Date().getTime()}.xlsx`);
  516. },
  517. // judgeRole(){
  518. // let {roles} = this.$store.state.user;
  519. // let role = roles.find(item => item === "syfz-purchaseorder") || "procurementManager";
  520. // return role;
  521. // },
  522. },
  523. created() {
  524. console.log("ADD CREATED", this.params);
  525. },
  526. mounted() {},
  527. destroyed() {},
  528. };
  529. </script>
  530. <template>
  531. <el-drawer
  532. direction="btt"
  533. size="100%"
  534. :with-header="false"
  535. :visible.sync="visible"
  536. @open="beforeOpen"
  537. @close="$emit('close')"
  538. v-loading="loading"
  539. >
  540. <el-form
  541. size="mini"
  542. label-position="right"
  543. ref="orderAddForm"
  544. label-width="140px"
  545. :model="params"
  546. :rules="rules"
  547. :key="count"
  548. >
  549. <el-card
  550. :body-style="{
  551. padding: '20px',
  552. display: 'flex',
  553. 'flex-wrap': 'wrap',
  554. }"
  555. style="margin: 10px"
  556. >
  557. <div
  558. slot="header"
  559. style="
  560. display: flex;
  561. justify-content: space-between;
  562. align-items: center;
  563. "
  564. >
  565. <h3>新增</h3>
  566. <div style="text-align: right">
  567. <el-button
  568. size="mini"
  569. type="primary"
  570. @click="handleSava"
  571. >保存</el-button>
  572. <el-button size="mini" @click="handleCancel">取消</el-button>
  573. </div>
  574. </div>
  575. <el-row style="display: flex; flex-wrap: wrap">
  576. <el-col
  577. v-for="(column, index) in columns"
  578. :key="index"
  579. :span="column.span || 6"
  580. >
  581. <el-form-item
  582. :prop="column.key"
  583. :label="column.title"
  584. v-if="column.isShow"
  585. >
  586. <el-input
  587. v-if="column.inputType === 'Input'"
  588. v-model="params[column.key]"
  589. :placeholder="column.placeholder"
  590. :clearable="column.clearable"
  591. :disabled="column.disabled"
  592. style="width: 100%;"
  593. >
  594. </el-input>
  595. <dr-popover-select
  596. v-if="column.inputType === 'PopoverSelect'"
  597. v-model="params[column.key]"
  598. :value-key="column.valueKey"
  599. :source.sync="params"
  600. :title="column.title"
  601. :type="column.referName"
  602. :disabled="column.disabled"
  603. :multiple="column.multiple"
  604. :placeholder="column.placeholder"
  605. :data-mapping="column.dataMapping"
  606. :query-params="column.queryParams"
  607. @change="handleReferChange"
  608. ></dr-popover-select>
  609. <el-input
  610. v-if="column.inputType === 'Textarea'"
  611. v-model="params[column.key]"
  612. type="textarea"
  613. :placeholder="column.placeholder"
  614. :clearable="column.clearable"
  615. :disabled="column.disabled"
  616. style="width: 100%"
  617. ></el-input>
  618. <el-input-number
  619. v-if="column.inputType === 'InputNumber'"
  620. v-model="params[column.key]"
  621. :precision="column.precision"
  622. :controls-position="column.controlsPosition"
  623. :placeholder="column.placeholder"
  624. :clearable="column.clearable"
  625. :disabled="column.disabled"
  626. style="width: 100%"
  627. >
  628. </el-input-number>
  629. <el-select
  630. v-if="column.inputType === 'Select'"
  631. v-model="params[column.key]"
  632. :disabled="column.disabled"
  633. :clearable="column.clearable"
  634. :placeholder="column.placeholder"
  635. style="width: 100%"
  636. filterable
  637. @change="handleSelectChange(column.key,column.referName)"
  638. >
  639. <el-option
  640. v-for="item in dict.type[column.referName]"
  641. :key="item.value"
  642. :label="item.label"
  643. :value="item.value"
  644. ></el-option>
  645. </el-select>
  646. <el-select
  647. v-if="column.inputType === 'TagSelect'"
  648. v-model="params[column.key]"
  649. multiple
  650. clearable
  651. collapse-tags
  652. :placeholder="column.placeholder"
  653. :clearable="column.clearable"
  654. :disabled="column.disabled"
  655. style="width: 100%"
  656. >
  657. <template #prefix>
  658. <el-icon
  659. class="el-icon-view"
  660. style="cursor: pointer"
  661. @click.stop="$message.info(234)"
  662. >
  663. </el-icon>
  664. </template>
  665. <el-option
  666. v-for="item in options"
  667. :key="item.value"
  668. :label="item.label"
  669. :value="item.value"
  670. ></el-option>
  671. </el-select>
  672. <el-date-picker
  673. v-if="column.inputType === 'DatePicker'"
  674. v-model="params[column.key]"
  675. :type="column.type"
  676. :placeholder="column.placeholder"
  677. :clearable="column.clearable"
  678. :disabled="column.disabled"
  679. :picker-options="column.pickerOptions"
  680. style="width: 100%"
  681. ></el-date-picker>
  682. <el-checkbox
  683. v-if="column.inputType === 'Checkbox'"
  684. v-model="params[column.key]"
  685. :disabled="column.disabled"
  686. true-label="Y"
  687. false-label="N"
  688. ></el-checkbox>
  689. <file-upload-center
  690. v-if="column.inputType === 'Upload'"
  691. v-model="params[column.key]"
  692. :file-type="column.fileType"
  693. ></file-upload-center>
  694. </el-form-item>
  695. </el-col>
  696. </el-row>
  697. </el-card>
  698. <el-card
  699. :body-style="{
  700. padding: '20px',
  701. display: 'flex',
  702. 'flex-wrap': 'wrap',
  703. position: 'relative',
  704. }"
  705. style="margin: 10px"
  706. >
  707. <el-tabs v-model="tabName" style="width: 100%" v-loading="tabLoading">
  708. <el-tab-pane
  709. v-for="(column, index) in tabColumns"
  710. :key="index"
  711. :label="column.title"
  712. :name="column.key"
  713. >
  714. <el-table
  715. :data="params[column.key]"
  716. style="width: 100%"
  717. :height="params[column.key].length ? 300 : 100"
  718. border
  719. >
  720. <el-table-column
  721. v-for="(cColumn, cIndex) in column.tableColumns"
  722. :key="cIndex"
  723. :label="cColumn.title"
  724. :width="cColumn.width || 80"
  725. >
  726. <template slot="header" slot-scope="scope">
  727. <span v-if="cColumn.require" style="color: #ff4949">*</span>
  728. <span>
  729. {{ cColumn.title }}
  730. </span>
  731. </template>
  732. <template slot-scope="scope">
  733. <el-form-item
  734. label-width="0"
  735. :prop="`${column.key}.${scope.$index}.${[cColumn.key]}`"
  736. :rules="{ required: cColumn.require || false, message: `${cColumn.title}不能为空`, trigger: 'change' }"
  737. >
  738. <el-tag v-if="cColumn.key === 'index'" >
  739. {{ scope.$index + 1 }}
  740. </el-tag>
  741. <el-input
  742. v-if="cColumn.inputType === 'Input'"
  743. v-model="scope.row[cColumn.key]"
  744. :placeholder="cColumn.placeholder"
  745. :clearable="cColumn.clearable"
  746. :disabled="cColumn.disabled"
  747. size="mini"
  748. style="width: 100%"
  749. ></el-input>
  750. <!-- -->
  751. <dr-popover-select
  752. v-if="cColumn.inputType === 'PopoverSelect'"
  753. v-model="scope.row[cColumn.key]"
  754. :source.sync="scope.row"
  755. :title="cColumn.title"
  756. :value-key="cColumn.valueKey"
  757. :type="cColumn.referName"
  758. :disabled="cColumn.disabled"
  759. :multiple="cColumn.multiple"
  760. :placeholder="cColumn.placeholder"
  761. :data-mapping="cColumn.dataMapping"
  762. :query-params="cColumn.queryParams"
  763. @change="handleTabReferChange"
  764. size="mini"
  765. >
  766. </dr-popover-select>
  767. <el-input-number
  768. v-if="cColumn.inputType === 'InputNumber'"
  769. v-model="scope.row[cColumn.key]"
  770. :precision="cColumn.precision"
  771. :controls-position="cColumn.controlsPosition"
  772. :placeholder="cColumn.placeholder"
  773. @change="handleInputChange(scope.row, cColumn.key)"
  774. :clearable="cColumn.clearable"
  775. :disabled="cColumn.disabled"
  776. :min="cColumn.key === 'reservedQty' ? 0 : -Infinity"
  777. size="mini"
  778. style="width: 100%"
  779. ></el-input-number>
  780. <el-select
  781. v-if="cColumn.inputType === 'Select'"
  782. v-model="scope.row[cColumn.key]"
  783. filterable
  784. size="mini"
  785. :disabled="cColumn.disabled"
  786. :clearable="cColumn.clearable"
  787. :placeholder="cColumn.placeholder"
  788. style="width: 100%"
  789. @change="handleTabSelectChange(cColumn.key,scope.row)"
  790. >
  791. <el-option
  792. v-for="item in dict.type[cColumn.referName]"
  793. :key="item.value"
  794. :label="item.label"
  795. :value="item.value"
  796. ></el-option>
  797. </el-select>
  798. <el-checkbox
  799. v-if="cColumn.inputType === 'Checkbox'"
  800. v-model="scope.row[cColumn.key]"
  801. :disabled="cColumn.disabled"
  802. true-label="Y"
  803. false-label="N"
  804. @change="handleTabCheckbox(cColumn.key,scope.row)"
  805. ></el-checkbox>
  806. </el-form-item>
  807. </template>
  808. </el-table-column>
  809. <el-table-column fixed="right" label="操作" width="80">
  810. <template slot-scope="scope">
  811. <el-button
  812. @click.native.prevent="
  813. delTableRow(params[tabName], scope.$index)
  814. "
  815. type="text"
  816. size="small"
  817. >
  818. 删行
  819. </el-button>
  820. </template>
  821. </el-table-column>
  822. </el-table>
  823. </el-tab-pane>
  824. </el-tabs>
  825. <el-row style="position: absolute; top: 20px; right: 20px">
  826. <el-button size="mini" @click="addTableRow(params[tabName])"
  827. >增行</el-button>
  828. <BatchImport
  829. v-if="role === 'procurementManager'"
  830. ref="batchImport"
  831. @import="handelImport"
  832. @temDownload="handleTemDownload"
  833. ></BatchImport>
  834. </el-row>
  835. </el-card>
  836. </el-form>
  837. </el-drawer>
  838. </template>