index.vue 34 KB

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