index.vue 29 KB

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