index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. <script>
  2. import useColumns from "./columns";
  3. import {EXIST} from "@/api/business/purchase/catalogue";
  4. import {ITEM, SAVE} from "@/api/business/purchase/apply";
  5. import {tax, unit, currency} from "@/components/popover-select-v2/fetch";
  6. // 用于回显参照框数据
  7. import {getRefer} from '@/api/purchase/basic.js'
  8. const fetchExist = async (prop) => {
  9. try {
  10. // try
  11. const {code, data} = await EXIST(prop);
  12. if (code === 200) return data;
  13. } catch (err) {
  14. // catch
  15. console.error(err);
  16. } finally {
  17. // finally
  18. }
  19. };
  20. export default {
  21. name: "EditDrawer",
  22. props: {
  23. dict: {
  24. type: Object,
  25. },
  26. selectData: {
  27. type: [Array],
  28. require: true,
  29. },
  30. },
  31. components: {
  32. ElSuperForm: () => import("@/components/super-form/index.vue"),
  33. ElSuperTable: () => import("@/components/super-table/index.vue"),
  34. ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
  35. ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
  36. },
  37. data() {
  38. const {
  39. TabColumns,
  40. TableColumns,
  41. TabColumns: [
  42. {
  43. item: {key: tabName},
  44. },
  45. ],
  46. } = useColumns();
  47. const rules = this.$init.rules([...TabColumns, ...TableColumns]);
  48. const params = this.$init.params([...TabColumns, ...TableColumns]);
  49. return {
  50. title: "编 辑",
  51. width: "100%",
  52. visible: false,
  53. loading: false,
  54. rules: rules,
  55. params: params,
  56. tabName: tabName,
  57. TabColumns: TabColumns,
  58. TableColumns: TableColumns,
  59. delDemandItemList: [],
  60. };
  61. },
  62. computed: {
  63. disabled: {
  64. get() {
  65. const {
  66. selectData,
  67. selectData: [{status} = {}],
  68. } = this.$props;
  69. if (selectData.length !== 1) {
  70. return true;
  71. }
  72. if (selectData.length === 1 && status === "1") {
  73. return true;
  74. }
  75. if (selectData.length === 1 && status === "2") {
  76. return true;
  77. }
  78. },
  79. set() {
  80. },
  81. },
  82. priceApply: {
  83. get() {
  84. this.params.priceApplyItems = this.params.priceApplyItems.map(
  85. (item, index) => ({
  86. ...item,
  87. $index: index,
  88. })
  89. );
  90. return {
  91. priceApplyItems: this.params.priceApplyItems.filter(
  92. ({delFlag}) => delFlag !== "2"
  93. ),
  94. };
  95. },
  96. set() {
  97. },
  98. },
  99. },
  100. watch: {},
  101. methods: {
  102. //
  103. async changeMaterialName(prop) {
  104. console.log('prop', prop);
  105. const {selectData} = prop;
  106. const {
  107. puOrg,
  108. customer,
  109. customerName,
  110. supplier,
  111. currency,
  112. currencyCode,
  113. currencyName,
  114. } = this.params;
  115. console.log('selectData', selectData)
  116. const {nickName: createByName} = this.$store.state.user;
  117. if (selectData.length) {
  118. this.params[this.tabName].splice(-1);
  119. }
  120. for (const item of selectData) {
  121. console.log('item', item)
  122. this.loading = true;
  123. const {tax: taxName, unitName, code: materialCode} = item;
  124. // task 1
  125. const {ntaxrate} = await tax(taxName);
  126. // task 2
  127. const {
  128. id: puUnit,
  129. code: puUnitCode,
  130. name: puUnitName,
  131. } = await unit(unitName);
  132. // task 3
  133. const {
  134. recentlyPrice = "0",
  135. isApprovalFirst = "N",
  136. purchasequantity,
  137. recentlyPriceDate
  138. } = await fetchExist({puOrg, customer, supplier, materialCode, customerName: "",priceType: prop.row.priceType});
  139. this.loading = false;
  140. await this.onRowAdd(this.tabName, {
  141. ...item,
  142. currency: currency,
  143. currencyCode: currencyCode,
  144. currencyName: currencyName,
  145. unit: puUnit,
  146. unitCode: puUnitCode,
  147. unitName: puUnitName,
  148. puUnit: puUnit,
  149. puUnitCode: puUnitCode,
  150. puUnitName: puUnitName,
  151. recentlyPrice,
  152. isApprovalFirst,
  153. recentlyPriceDate: recentlyPriceDate,
  154. yPurchaseQuantity: purchasequantity,
  155. tax: Number(ntaxrate === "0E-8" ? 0 : ntaxrate),
  156. createByName: createByName,
  157. updateByName: createByName,
  158. id: null,
  159. });
  160. }
  161. },
  162. //
  163. async changeCustomerName(prop) {
  164. console.log("prop", prop)
  165. const {
  166. puOrg,
  167. supplier,
  168. currency,
  169. currencyCode,
  170. currencyName,
  171. } = this.params;
  172. const {
  173. recentlyPrice,
  174. isApprovalFirst,
  175. purchasequantity,
  176. recentlyPriceDate
  177. } = await fetchExist({
  178. puOrg,
  179. supplier,
  180. materialCode: prop.row.materialCode,
  181. customer: prop.row.customerName ? prop.row.customer : '',
  182. customerName: prop.row.customerName,
  183. priceType: prop.row.priceType
  184. });
  185. prop.row.yPurchaseQuantity = purchasequantity
  186. prop.row.recentlyPrice = recentlyPrice
  187. prop.row.isApprovalFirst = isApprovalFirst
  188. prop.row.recentlyPriceDate = recentlyPriceDate
  189. },
  190. //
  191. async fetchItem(prop) {
  192. try {
  193. // try
  194. this.loading = true;
  195. const {tabName, TabColumns} = this;
  196. const {TableColumns} = TabColumns.find(
  197. ({item: {key}}) => key === tabName
  198. );
  199. const {code, data} = await ITEM(prop, false);
  200. if (code === 200) {
  201. this.params = data;
  202. this.params.priceApplyItems = data.priceApplyItems.map((item) => ({
  203. ...this.$init.params(TableColumns),
  204. ...item,
  205. }));
  206. return true;
  207. } else {
  208. return false;
  209. }
  210. } catch (err) {
  211. // catch
  212. console.error(err);
  213. } finally {
  214. // finally
  215. this.loading = false;
  216. }
  217. },
  218. //
  219. async onOpen() {
  220. const {
  221. selectData: [{id}],
  222. } = this.$props;
  223. this.visible = await this.fetchItem(id);
  224. },
  225. //
  226. async onHide() {
  227. const {TabColumns, TableColumns} = useColumns();
  228. this.visible = false;
  229. this.params = this.$init.params([...TabColumns, ...TableColumns]);
  230. this.$emit("success");
  231. this.delDemandItemList = []
  232. },
  233. //
  234. async onRowAdd(prop, pushParams = {}) {
  235. this.$refs.superForm.validate(async (valid) => {
  236. if (valid) {
  237. const {TabColumns} = this;
  238. const {TableColumns} = TabColumns.find(
  239. ({item: {key}}) => key === prop
  240. );
  241. this.params[prop].push({
  242. delFlag: "0",
  243. ...this.$init.params(TableColumns),
  244. ...pushParams,
  245. });
  246. }
  247. });
  248. },
  249. //
  250. async onRowRemove(prop, scope) {
  251. console.log('prop', prop)
  252. console.log('scope', scope)
  253. // const {
  254. // row: {$index},
  255. // } = scope;
  256. // this.params[prop] = this.params[prop].map((item, index) => ({
  257. // ...item,
  258. // delFlag: index === $index ? "2" : item.delFlag,
  259. // }));
  260. scope.row.delFlag = '2'
  261. let delList = []
  262. delList = this.params[prop].filter(item => {
  263. return item.delFlag == '2'
  264. })
  265. this.params[prop] = this.params[prop].filter(item => {
  266. return item.delFlag == '0'
  267. })
  268. this.delDemandItemList.push(...delList)
  269. console.log('删除的数组',this.delDemandItemList)
  270. console.log('this.params[prop]', this.params[prop])
  271. },
  272. //
  273. async useSubmit(prop) {
  274. this.$refs[prop].validate(async (valid) => {
  275. console.log(this.params);
  276. if (valid) {
  277. try {
  278. this.loading = true;
  279. let list = []
  280. list.push(...this.params.priceApplyItems, ...this.delDemandItemList)
  281. this.params.priceApplyItems = this.params.priceApplyItems.filter(
  282. (item) => item.materialName
  283. );
  284. // 深拷贝一下参数对象
  285. let param = JSON.parse(JSON.stringify(this.params))
  286. // console.log('深拷贝对象',param);
  287. param.priceApplyItems = list
  288. let tishi = param.priceApplyItems.filter(item => {return (item.priceDiffer && item.delFlag == '0' && item.priceDiffer !== 0)})
  289. console.log('筛选', tishi)
  290. let tishiMsg = tishi.map(item => {
  291. return `第${item.$index+1}行为价格调整`
  292. })
  293. console.log(tishiMsg)
  294. if(tishiMsg.length !== 0) {
  295. this.$modal.confirm(tishiMsg+ '请核对后再次提交').then(async () =>{
  296. const {msg, code} = await SAVE(param);
  297. if (code === 200) {
  298. this.onHide();
  299. this.$emit("success");
  300. this.$notify.success(msg);
  301. this.delDemandItemList = []
  302. }
  303. }).catch(() => {});
  304. } else {
  305. const {msg, code} = await SAVE(param);
  306. if (code === 200) {
  307. this.onHide();
  308. this.$emit("success");
  309. this.$notify.success(msg);
  310. this.delDemandItemList = []
  311. }
  312. }
  313. } catch (err) {
  314. // catch
  315. console.error(err);
  316. } finally {
  317. // finally
  318. this.loading = false;
  319. }
  320. } else {
  321. return false;
  322. }
  323. });
  324. },
  325. // 粘贴
  326. async pasteMe(e, scope, index, prop) {
  327. this.$modal.loading("正在处理数据...");
  328. e.preventDefault() //阻止默认粘贴事件
  329. let source = e.clipboardData.getData("Text");
  330. console.log('scope', scope.column.property)
  331. console.log('index', index)
  332. // 首先对源头进行解析
  333. let rows = source.split("\r\n"); // 拆成一个数组
  334. // 数组去除空字符串
  335. rows = rows.filter(item => {
  336. return item && item.trim()
  337. })
  338. if (rows.length < 100) {
  339. if(scope.column.property == 'materialCode') {
  340. let rowList = []
  341. let newLine = []
  342. await getRefer({ type: 'MATERIAL_PARAM', materialCodeList: rows }).then(res => {
  343. if (res.code === 200) {
  344. rowList = res.rows
  345. }
  346. }).catch(err => {
  347. this.$modal.closeLoading();
  348. })
  349. const {
  350. puOrg,
  351. customer,
  352. customerName,
  353. supplier,
  354. currency,
  355. currencyCode,
  356. currencyName,
  357. } = this.params;
  358. const {TabColumns} = this;
  359. const {TableColumns} = TabColumns.find(
  360. ({item: {key}}) => key === prop
  361. );
  362. // console.log('kk', TableColumns)
  363. // console.log('this.$init.params(TableColumns)', this.$init.params(TableColumns))
  364. for (let i = 0; i<rowList.length; i++) {
  365. let line = {...this.$init.params(TableColumns)}
  366. console.log('line',line)
  367. const {nickName: createByName} = this.$store.state.user;
  368. const {ntaxrate} = await tax(rowList[i].materialRateName);
  369. // task 2
  370. const {
  371. id: puUnit,
  372. code: puUnitCode,
  373. name: puUnitName,
  374. } = await unit(rowList[i].unitIdName);
  375. // task 3
  376. const {
  377. recentlyPrice = "0",
  378. isApprovalFirst = "N",
  379. purchasequantity,
  380. recentlyPriceDate
  381. } = await fetchExist({puOrg, customer, supplier, materialCode: rowList[i].code, customerName: "", priceType: line.priceType});
  382. line.delFlag = '0'
  383. line.materialCode = rowList[i].code
  384. line.material = rowList[i].id
  385. line.materialName = rowList[i].name
  386. line.specification = rowList[i].specification
  387. line.model = rowList[i].model
  388. line.manufacturerName = rowList[i].manufacturerIdName
  389. line.unit = puUnit,
  390. line.unitCode = puUnitCode,
  391. line.unitName = puUnitName,
  392. line.puUnit = puUnit,
  393. line.puUnitCode = puUnitCode,
  394. line.puUnitName = puUnitName,
  395. line.recentlyPrice = recentlyPrice
  396. line.isApprovalFirst = isApprovalFirst
  397. line.recentlyPriceDate = recentlyPriceDate,
  398. line.yPurchaseQuantity = purchasequantity,
  399. line.tax = Number(ntaxrate === "0E-8" ? 0 : ntaxrate),
  400. line.createByName = createByName,
  401. line.updateByName = createByName,
  402. line.currency = currency
  403. line.currencyCode = currencyCode
  404. line.currencyName = currencyName
  405. newLine.push(line)
  406. console.log('临时数组', newLine)
  407. }
  408. // 删除指定下标
  409. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  410. this.$modal.closeLoading();
  411. this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
  412. } else if(scope.column.property == 'taxPrice') {
  413. console.log('复制内容:', rows)
  414. let newLine = []
  415. const {TabColumns} = this;
  416. const {TableColumns} = TabColumns.find(
  417. ({item: {key}}) => key === prop
  418. );
  419. if(this.params[prop].length <= 1) {
  420. for (let i = 0; i<rows.length; i++) {
  421. let line = {...this.$init.params(TableColumns)}
  422. line.taxPrice = rows[i]
  423. newLine.push(line)
  424. }
  425. // 删除指定下标
  426. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  427. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  428. // this.$refs.table.doLayout()
  429. this.$modal.closeLoading();
  430. } else {
  431. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  432. this.params[prop][i].taxPrice = rows[j]
  433. }
  434. // this.$refs.table.doLayout()
  435. console.log(this.params[prop])
  436. this.$modal.closeLoading();
  437. }
  438. } else if(scope.column.property == 'supplierName') {
  439. console.log('复制内容:', rows)
  440. let newLine = []
  441. const {TabColumns} = this;
  442. const {TableColumns} = TabColumns.find(
  443. ({item: {key}}) => key === prop
  444. );
  445. if(this.params[prop].length <= 1) {
  446. for (let i = 0; i<rows.length; i++) {
  447. let line = {...this.$init.params(TableColumns)}
  448. line.supplierName = rows[i]
  449. newLine.push(line)
  450. }
  451. // 删除指定下标
  452. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  453. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  454. // this.$refs.table.doLayout()
  455. this.$modal.closeLoading();
  456. } else {
  457. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  458. this.params[prop][i].supplierName = rows[j]
  459. }
  460. // this.$refs.table.doLayout()
  461. console.log(this.params[prop])
  462. this.$modal.closeLoading();
  463. }
  464. } else if(scope.column.property == 'bidPrice') {
  465. console.log('复制内容:', rows)
  466. let newLine = []
  467. const {TabColumns} = this;
  468. const {TableColumns} = TabColumns.find(
  469. ({item: {key}}) => key === prop
  470. );
  471. if(this.params[prop].length <= 1) {
  472. for (let i = 0; i<rows.length; i++) {
  473. let line = {...this.$init.params(TableColumns)}
  474. line.bidPrice = rows[i]
  475. newLine.push(line)
  476. }
  477. // 删除指定下标
  478. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  479. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  480. // this.$refs.table.doLayout()
  481. this.$modal.closeLoading();
  482. } else {
  483. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  484. this.params[prop][i].bidPrice = rows[j]
  485. }
  486. // this.$refs.table.doLayout()
  487. console.log(this.params[prop])
  488. this.$modal.closeLoading();
  489. }
  490. } else if(scope.column.property == 'unitPrice') {
  491. console.log('复制内容:', rows)
  492. let newLine = []
  493. const {TabColumns} = this;
  494. const {TableColumns} = TabColumns.find(
  495. ({item: {key}}) => key === prop
  496. );
  497. if(this.params[prop].length <= 1) {
  498. for (let i = 0; i<rows.length; i++) {
  499. let line = {...this.$init.params(TableColumns)}
  500. line.unitPrice = rows[i]
  501. newLine.push(line)
  502. }
  503. // 删除指定下标
  504. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  505. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  506. // this.$refs.table.doLayout()
  507. this.$modal.closeLoading();
  508. } else {
  509. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  510. this.params[prop][i].unitPrice = rows[j]
  511. }
  512. // this.$refs.table.doLayout()
  513. console.log(this.params[prop])
  514. this.$modal.closeLoading();
  515. }
  516. } else if(scope.column.property == 'supplierName1') {
  517. console.log('复制内容:', rows)
  518. let newLine = []
  519. const {TabColumns} = this;
  520. const {TableColumns} = TabColumns.find(
  521. ({item: {key}}) => key === prop
  522. );
  523. if(this.params[prop].length <= 1) {
  524. for (let i = 0; i<rows.length; i++) {
  525. let line = {...this.$init.params(TableColumns)}
  526. line.supplierName1 = rows[i]
  527. newLine.push(line)
  528. }
  529. // 删除指定下标
  530. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  531. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  532. // this.$refs.table.doLayout()
  533. this.$modal.closeLoading();
  534. } else {
  535. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  536. this.params[prop][i].supplierName1 = rows[j]
  537. }
  538. // this.$refs.table.doLayout()
  539. console.log(this.params[prop])
  540. this.$modal.closeLoading();
  541. }
  542. } else if(scope.column.property == 'bidPrice1') {
  543. console.log('复制内容:', rows)
  544. let newLine = []
  545. const {TabColumns} = this;
  546. const {TableColumns} = TabColumns.find(
  547. ({item: {key}}) => key === prop
  548. );
  549. if(this.params[prop].length <= 1) {
  550. for (let i = 0; i<rows.length; i++) {
  551. let line = {...this.$init.params(TableColumns)}
  552. line.bidPrice1 = rows[i]
  553. newLine.push(line)
  554. }
  555. // 删除指定下标
  556. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  557. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  558. // this.$refs.table.doLayout()
  559. this.$modal.closeLoading();
  560. } else {
  561. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  562. this.params[prop][i].bidPrice1 = rows[j]
  563. }
  564. // this.$refs.table.doLayout()
  565. console.log(this.params[prop])
  566. this.$modal.closeLoading();
  567. }
  568. } else if(scope.column.property == 'unitPrice1') {
  569. console.log('复制内容:', rows)
  570. let newLine = []
  571. const {TabColumns} = this;
  572. const {TableColumns} = TabColumns.find(
  573. ({item: {key}}) => key === prop
  574. );
  575. if(this.params[prop].length <= 1) {
  576. for (let i = 0; i<rows.length; i++) {
  577. let line = {...this.$init.params(TableColumns)}
  578. line.unitPrice1 = rows[i]
  579. newLine.push(line)
  580. }
  581. // 删除指定下标
  582. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  583. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  584. // this.$refs.table.doLayout()
  585. this.$modal.closeLoading();
  586. } else {
  587. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  588. this.params[prop][i].unitPrice1 = rows[j]
  589. }
  590. // this.$refs.table.doLayout()
  591. console.log(this.params[prop])
  592. this.$modal.closeLoading();
  593. }
  594. } else if(scope.column.property == 'supplierName2') {
  595. console.log('复制内容:', rows)
  596. let newLine = []
  597. const {TabColumns} = this;
  598. const {TableColumns} = TabColumns.find(
  599. ({item: {key}}) => key === prop
  600. );
  601. if(this.params[prop].length <= 1) {
  602. for (let i = 0; i<rows.length; i++) {
  603. let line = {...this.$init.params(TableColumns)}
  604. line.supplierName2 = rows[i]
  605. newLine.push(line)
  606. }
  607. // 删除指定下标
  608. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  609. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  610. // this.$refs.table.doLayout()
  611. this.$modal.closeLoading();
  612. } else {
  613. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  614. this.params[prop][i].supplierName2 = rows[j]
  615. }
  616. // this.$refs.table.doLayout()
  617. console.log(this.params[prop])
  618. this.$modal.closeLoading();
  619. }
  620. } else if(scope.column.property == 'bidPrice2') {
  621. console.log('复制内容:', rows)
  622. let newLine = []
  623. const {TabColumns} = this;
  624. const {TableColumns} = TabColumns.find(
  625. ({item: {key}}) => key === prop
  626. );
  627. if(this.params[prop].length <= 1) {
  628. for (let i = 0; i<rows.length; i++) {
  629. let line = {...this.$init.params(TableColumns)}
  630. line.bidPrice2 = rows[i]
  631. newLine.push(line)
  632. }
  633. // 删除指定下标
  634. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  635. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  636. // this.$refs.table.doLayout()
  637. this.$modal.closeLoading();
  638. } else {
  639. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  640. this.params[prop][i].bidPrice2 = rows[j]
  641. }
  642. // this.$refs.table.doLayout()
  643. console.log(this.params[prop])
  644. this.$modal.closeLoading();
  645. }
  646. } else if(scope.column.property == 'unitPrice2') {
  647. console.log('复制内容:', rows)
  648. let newLine = []
  649. const {TabColumns} = this;
  650. const {TableColumns} = TabColumns.find(
  651. ({item: {key}}) => key === prop
  652. );
  653. if(this.params[prop].length <= 1) {
  654. for (let i = 0; i<rows.length; i++) {
  655. let line = {...this.$init.params(TableColumns)}
  656. line.unitPrice2 = rows[i]
  657. newLine.push(line)
  658. }
  659. // 删除指定下标
  660. this.params[prop].splice(index,this.params[prop].length - index,...newLine)
  661. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  662. // this.$refs.table.doLayout()
  663. this.$modal.closeLoading();
  664. } else {
  665. for(let i = index , j = 0; i < this.params[prop].length; i++, j++) {
  666. this.params[prop][i].unitPrice2 = rows[j]
  667. }
  668. // this.$refs.table.doLayout()
  669. console.log(this.params[prop])
  670. this.$modal.closeLoading();
  671. }
  672. }
  673. } else {
  674. this.$modal.notifyWarning("复制长度不能超过100!");
  675. this.$modal.closeLoading();
  676. }
  677. },
  678. },
  679. created() {
  680. },
  681. mounted() {
  682. },
  683. destroyed() {
  684. },
  685. };
  686. </script>
  687. <template>
  688. <el-button
  689. v-bind="$attrs"
  690. v-on="$listeners"
  691. :disabled="disabled"
  692. @click="onOpen"
  693. >
  694. {{ title }}
  695. <el-drawer
  696. :show-close="false"
  697. :size="width"
  698. :title="title"
  699. :visible.sync="visible"
  700. append-to-body
  701. destroy-on-close
  702. @close="onHide"
  703. >
  704. <template slot="title">
  705. <span>{{ title }}</span>
  706. <el-button
  707. type="primary"
  708. :size="$attrs.size"
  709. :loading="loading"
  710. @click="useSubmit('superForm')"
  711. >
  712. 确 认
  713. </el-button>
  714. <el-button :size="$attrs.size" :loading="loading" @click="onHide">
  715. 取 消
  716. </el-button>
  717. </template>
  718. <el-super-form
  719. v-model="params"
  720. :dict="dict"
  721. :rules="rules"
  722. :size="$attrs.size"
  723. :columns="TableColumns"
  724. ref="superForm"
  725. label-width="auto"
  726. label-position="right"
  727. style="padding: 18px"
  728. >
  729. </el-super-form>
  730. <el-tabs v-model="tabName" style="padding: 0 18px 18px">
  731. <el-tab-pane
  732. v-for="({ item, TableColumns: columns }, index) in TabColumns"
  733. :key="index"
  734. :label="item.title"
  735. :name="item.key"
  736. lazy
  737. >
  738. <div v-loading="loading" style="height: 250px; display: flex">
  739. <el-super-ux-table
  740. v-model="priceApply[item.key]"
  741. :dict="dict"
  742. :ref="tabName"
  743. height="250"
  744. :columns="columns"
  745. :size="$attrs.size"
  746. >
  747. <template slot="materialName" slot-scope="scope">
  748. <component
  749. v-bind="scope.attr"
  750. v-model="scope.row[scope.item.key]"
  751. :size="$attrs.size"
  752. :source.sync="scope.row"
  753. @change="changeMaterialName({ ...scope, selectData: $event })"
  754. >
  755. </component>
  756. </template>
  757. <template slot="materialCode" slot-scope="scope">
  758. <component
  759. v-bind="scope.attr"
  760. v-model="scope.row[scope.item.key]"
  761. :size="$attrs.size"
  762. :source.sync="scope.row"
  763. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  764. >
  765. </component>
  766. </template>
  767. <template slot="taxPrice" slot-scope="scope">
  768. <component
  769. v-bind="scope.attr"
  770. v-model="scope.row[scope.item.key]"
  771. :size="$attrs.size"
  772. :source.sync="scope.row"
  773. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  774. >
  775. </component>
  776. </template>
  777. <template slot="supplierName" slot-scope="scope">
  778. <component
  779. v-bind="scope.attr"
  780. v-model="scope.row[scope.item.key]"
  781. :size="$attrs.size"
  782. :source.sync="scope.row"
  783. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  784. >
  785. </component>
  786. </template>
  787. <template slot="bidPrice" slot-scope="scope">
  788. <component
  789. v-bind="scope.attr"
  790. v-model="scope.row[scope.item.key]"
  791. :size="$attrs.size"
  792. :source.sync="scope.row"
  793. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  794. >
  795. </component>
  796. </template>
  797. <template slot="unitPrice" slot-scope="scope">
  798. <component
  799. v-bind="scope.attr"
  800. v-model="scope.row[scope.item.key]"
  801. :size="$attrs.size"
  802. :source.sync="scope.row"
  803. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  804. >
  805. </component>
  806. </template>
  807. <template slot="supplierName1" slot-scope="scope">
  808. <component
  809. v-bind="scope.attr"
  810. v-model="scope.row[scope.item.key]"
  811. :size="$attrs.size"
  812. :source.sync="scope.row"
  813. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  814. >
  815. </component>
  816. </template>
  817. <template slot="bidPrice1" slot-scope="scope">
  818. <component
  819. v-bind="scope.attr"
  820. v-model="scope.row[scope.item.key]"
  821. :size="$attrs.size"
  822. :source.sync="scope.row"
  823. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  824. >
  825. </component>
  826. </template>
  827. <template slot="unitPrice1" slot-scope="scope">
  828. <component
  829. v-bind="scope.attr"
  830. v-model="scope.row[scope.item.key]"
  831. :size="$attrs.size"
  832. :source.sync="scope.row"
  833. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  834. >
  835. </component>
  836. </template>
  837. <template slot="supplierName2" slot-scope="scope">
  838. <component
  839. v-bind="scope.attr"
  840. v-model="scope.row[scope.item.key]"
  841. :size="$attrs.size"
  842. :source.sync="scope.row"
  843. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  844. >
  845. </component>
  846. </template>
  847. <template slot="bidPrice2" slot-scope="scope">
  848. <component
  849. v-bind="scope.attr"
  850. v-model="scope.row[scope.item.key]"
  851. :size="$attrs.size"
  852. :source.sync="scope.row"
  853. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  854. >
  855. </component>
  856. </template>
  857. <template slot="unitPrice2" slot-scope="scope">
  858. <component
  859. v-bind="scope.attr"
  860. v-model="scope.row[scope.item.key]"
  861. :size="$attrs.size"
  862. :source.sync="scope.row"
  863. @paste.native="pasteMe($event, scope, scope.rowIndex, tabName)"
  864. >
  865. </component>
  866. </template>
  867. <template slot="customerName" slot-scope="scope">
  868. <component
  869. v-bind="scope.attr"
  870. v-model="scope.row[scope.item.key]"
  871. :size="$attrs.size"
  872. :source.sync="scope.row"
  873. @input="changeCustomerName({ ...scope, selectData: $event })"
  874. >
  875. </component>
  876. </template>
  877. <ux-table-column fixed="right" title="操作" width="100">
  878. <template slot="header" slot-scope="scope">
  879. <el-button :size="$attrs.size" @click="onRowAdd(tabName)">
  880. 新增
  881. </el-button>
  882. </template>
  883. <template slot-scope="scope">
  884. <el-button
  885. :size="$attrs.size"
  886. @click.native.prevent="onRowRemove(tabName, scope)"
  887. >
  888. 删除
  889. </el-button>
  890. </template>
  891. </ux-table-column>
  892. </el-super-ux-table>
  893. </div>
  894. </el-tab-pane>
  895. </el-tabs>
  896. </el-drawer>
  897. </el-button>
  898. </template>
  899. <style scoped>
  900. ::v-deep .el-table__row.is-hidden {
  901. display: none;
  902. }
  903. </style>