index.vue 34 KB

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