index.vue 32 KB

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