index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. <!-- 采购订单修订—— 列表 -->
  2. <script>
  3. import { TableColumns, SearchColumns, TabColumns, SelectColumns } from "./column";
  4. import orderApi from "@/api/business/purchase/purchase-order";
  5. import {
  6. initPage,
  7. initParams,
  8. // initDicts,
  9. } from "@/utils/init/index.js";
  10. import { initDicts } from "@/utils/init.js";
  11. const allColumns = [...TableColumns, ...SearchColumns];
  12. TabColumns.forEach(column =>{
  13. allColumns.push(...column.tableColumns)
  14. })
  15. export default {
  16. name: "PuchaseOrder",
  17. // dicts: initDicts(SelectColumns),
  18. dicts: [...initDicts(allColumns)],
  19. components: {
  20. AddDrawer: () => import('./add/index.vue'),
  21. SeeDrawer: () => import('./see/index.vue'),
  22. EditDrawer: () => import('./edit/index.vue'),
  23. PurchaseReturnDrawer: () => import('./purchaseReturn/index.vue'),
  24. ElSuperTable: () => import("@/components/super-table/index.vue"),
  25. ElSuperSearch: () => import("@/components/super-search/index.vue"),
  26. },
  27. data() {
  28. const initTabColumns = () => TabColumns;
  29. return {
  30. loading: false,
  31. tabLoading:false,
  32. page: { pageNum: 1, pageSize: 10, total: 0 },
  33. searchColumns: SearchColumns,
  34. params: initParams(SearchColumns),
  35. tableColumns: TableColumns,
  36. tableData: [],
  37. tabColumns: initTabColumns(),
  38. tabName: "puOrderItemList",
  39. tabTableDatas: {
  40. puOrderItemList: [],
  41. puOrderExecuteList: [],
  42. },
  43. checkedList: [],
  44. // 子表Select
  45. checkedTabList: [],
  46. // 主表点击信息
  47. primaryResource:{},
  48. timer:300,
  49. timeOut:null,
  50. };
  51. },
  52. computed: {
  53. $dicts: {
  54. get: function () {
  55. return this.dict.type;
  56. },
  57. },
  58. },
  59. created() {
  60. this.fetchList(this.params, this.page);
  61. // this.handleRefreshList();
  62. },
  63. methods: {
  64. async fetchList(data, params) {
  65. try {
  66. this.loading = true;
  67. params['isAsc'] = 'desc';
  68. params['orderByColumn'] = 'updateTime';
  69. const { code, msg, rows, total } = await orderApi.list(data, params);
  70. if (code === 200) {
  71. this.page.total = total;
  72. this.tableData = rows;
  73. }
  74. } catch (err) {
  75. //
  76. } finally {
  77. this.loading = false;
  78. for (const key in this.tabTableDatas) {
  79. this.tabTableDatas[key] = [];
  80. }
  81. }
  82. },
  83. async handleDownload(){
  84. console.log(this.params,'条件');
  85. this.download('/pu/order/export', this.params, `采购订单维护${new Date().getTime()}.xlsx`);
  86. },
  87. async jumpFlow(row){
  88. const {name} = this.$store.state.user;
  89. try {
  90. let {code,msg,oaUrl} = await orderApi.toOA(name,row.flowId);
  91. if(code == 200){
  92. window.open(oaUrl)
  93. }
  94. } catch (error) {
  95. }finally{
  96. }
  97. },
  98. setSelectable(){
  99. return true
  100. },
  101. setTabSelectable(){
  102. if(this.tabName === 'puOrderItemList'){
  103. return true
  104. }
  105. return false
  106. },
  107. // 刷新操作
  108. handleRefreshList() {
  109. this.page.pageNum = 1;
  110. this.page.pageSize = 10;
  111. this.$refs.purchaseTable.$refs.superTable.clearSelection();
  112. for (const key in this.tabTableDatas) {
  113. this.tabTableDatas[key] = []
  114. }
  115. this.$refs.puOrderItemList[0].$refs.superTable.clearSelection();
  116. // this.checkedList = [];
  117. // this.checkedTabList = [];
  118. this.primaryResource = {};
  119. this.fetchList(this.params, this.page);
  120. },
  121. // 查询操作
  122. handleQueryList() {
  123. let {date} = this.params;
  124. this.params.startDate = date ? date[0] :'';
  125. this.params.endDate = date ? date[1] : '';
  126. this.fetchList(this.params, this.page);
  127. },
  128. // 重置操作
  129. handleResetList() {
  130. this.page.pageNum = 1;
  131. this.page.pageSize = 10;
  132. this.params = initParams(SearchColumns);
  133. this.fetchList(this.params, this.page);
  134. },
  135. handleTabClick() { },
  136. // 新增
  137. handleOpenAddDrawer(copyVal) {
  138. const { setVisible, setCopyParams } = this.$refs.addDrawerFef;
  139. setVisible(true,(copyVal.id && copyVal.id != '') ? true :false);
  140. copyVal.id && copyVal.id != '' && setCopyParams(copyVal.id);
  141. },
  142. // 复制
  143. handleCopy() {
  144. this.handleOpenAddDrawer(this.checkedList[0]);
  145. },
  146. // 查看
  147. async handleOpenSeeDrawer(row) {
  148. window.clearInterval(this.timeOut);
  149. const { id } = row;
  150. const { setVisible, fetchItem } = this.$refs.seeDrawerRef;
  151. await setVisible(true);
  152. await fetchItem(id);
  153. },
  154. // 编辑、修订
  155. async handleOpenEditDrawer(row) {
  156. const { id } = row;
  157. const { setVisible, fetchItem } = this.$refs.editDrawerRef;
  158. await setVisible(true);
  159. await fetchItem(id);
  160. },
  161. // 获取子表信息
  162. handleDetailsData(row) {
  163. window.clearTimeout(this.timeOut);
  164. this.timeOut = setTimeout(async () =>{
  165. try {
  166. this.tabLoading = true;
  167. this.primaryResource = row;
  168. this.checkedTabList = [];
  169. const { code, msg, data } = await orderApi.details(row.id);
  170. if (code === 200) {
  171. // 物料信息:puOrderItemList 执行结果:puOrderExecuteList
  172. for (const key in this.tabTableDatas) {
  173. this.tabTableDatas[key] = data[key];
  174. }
  175. }
  176. } catch (err) {}
  177. finally{
  178. this.tabLoading = false;
  179. }
  180. },this.timer)
  181. },
  182. // 操作提示弹窗
  183. handleConfirmTips(success){
  184. this.$confirm('是否继续此操作?', '提示', {
  185. confirmButtonText: '确定',
  186. cancelButtonText: '取消',
  187. type: 'warning'
  188. }).then(() => {
  189. success();
  190. }).catch(() => {
  191. });
  192. },
  193. // 删除操作
  194. handleDeleteList(row) {
  195. try {
  196. this.loading = true;
  197. this.handleConfirmTips(async()=>{
  198. const { id } = row;
  199. const { code } = await orderApi.remove(id);
  200. if (code === 200) {
  201. this.handleRefreshList();
  202. }
  203. })
  204. } catch (err) {
  205. //
  206. } finally {
  207. this.loading = false;
  208. }
  209. },
  210. // 批量提交
  211. handleBatchSubmit(){
  212. let inconformity = this.checkedList.filter(row => !((row.status == '0' || row.status == '3') && row.isEnd === 'N'));
  213. if(!inconformity.length && this.checkedList.length){
  214. let puOrderIds = this.checkedList.map( item => Number(item.id));
  215. this.fetchSubmit(puOrderIds);
  216. }else{
  217. this.$notify({
  218. title: '警告',
  219. message: '当前选中存在不满足提交条件的数据!',
  220. type: 'warning'
  221. });
  222. }
  223. },
  224. // 提交
  225. handleSubmit(row) {
  226. let puOrderIds = [Number(row.id)];
  227. this.fetchSubmit(puOrderIds);
  228. },
  229. fetchSubmit(puOrderIds){
  230. let _this = this;
  231. this.handleConfirmTips(async()=>{
  232. try {
  233. _this.loading = true;
  234. let { code,msg } = await orderApi.submit({ puOrderIds,checkAmount:true});
  235. console.log(code,'code');
  236. if (code == 200) {
  237. _this.handleRefreshList();
  238. }else if(code == 10000){
  239. _this.$alert(msg, '提示', {
  240. showCancelButton: true,
  241. confirmButtonText: '置为0并提交',
  242. cancelButtonText: '取消',
  243. beforeClose: async(action, instance, done) => {
  244. if (action === 'confirm') {
  245. try {
  246. instance.confirmButtonLoading = true;
  247. instance.confirmButtonText = '执行中...';
  248. let { code,msg } = await orderApi.submit({ puOrderIds,checkAmount:false});
  249. if(code == 200){
  250. done();
  251. _this.handleRefreshList();
  252. }
  253. } catch (error) {
  254. }finally{
  255. instance.confirmButtonLoading = false;
  256. }
  257. } else {
  258. done();
  259. }
  260. }
  261. });
  262. }
  263. } catch (error) {}
  264. finally{
  265. this.loading = false;
  266. }
  267. })
  268. },
  269. // 判断“整单退回”按钮
  270. judgeIsAllReturn() {
  271. if (this.checkedList.length == 1) {
  272. // 非手工、状态:自由/驳回
  273. if (this.judgeIsOption('return',this.checkedList[0])) {
  274. // if (this.checkedList[0].source != 3 &&
  275. // (this.checkedList[0].status == 0 || this.checkedList[0].status == 3)
  276. // ) {
  277. return false
  278. }
  279. }
  280. return true;
  281. },
  282. // 整单退回
  283. handleAllReturn() {
  284. this.handleReturn(this.checkedList[0].id,[]);
  285. },
  286. // 判断“行退回”按钮
  287. judgeIsLineReturn() {
  288. if (this.checkedTabList.length == 1) {
  289. // 主信息:非手工、状态:自由/驳回
  290. if(this.judgeIsOption('return',this.primaryResource)){
  291. // if(this.primaryResource.source != 3 &&
  292. // (this.primaryResource.status == 0 || this.primaryResource.status == 3) ){
  293. return false
  294. }
  295. }
  296. return true;
  297. },
  298. // 行退回
  299. handleLineReturn(){
  300. let ids = this.checkedTabList.map(checked => checked.id);
  301. console.log(ids,'行退回ids');
  302. this.handleReturn(this.primaryResource.id,ids);
  303. },
  304. // 退回接口
  305. handleReturn(id,documentIds){
  306. this.$prompt('请输入退回原因', '提示', {
  307. confirmButtonText: '确定',
  308. cancelButtonText: '取消',
  309. inputPattern: /\s*\S+?/,
  310. inputErrorMessage: '退回原因不能为空'
  311. }).then(async ({ value }) => {
  312. let data = {
  313. id:Number(id),
  314. documentIds:documentIds.map(ids =>Number(ids)),
  315. baskCause: value,
  316. };
  317. console.log(data);
  318. try {
  319. let { code, msg } = await orderApi.documentsReturn(data);
  320. if (code === 200) {
  321. this.handleRefreshList();
  322. }
  323. } catch (error) {
  324. console.log(error,'error------------');
  325. }
  326. }).catch(() => { });
  327. },
  328. // 判断是否满足整单关闭
  329. judgeIsAllClose() {
  330. if (this.checkedList.length == 1) {
  331. // if (this.checkedList[0].status == 0) {
  332. if (this.judgeIsOption('allClose',this.checkedList[0])) {
  333. // 未审批状态下整单关闭
  334. return false
  335. }
  336. }
  337. return true;
  338. },
  339. // 整单关闭
  340. handleAllClose() {
  341. // 未审批状态下整单关闭
  342. try {
  343. this.handleConfirmTips(async() =>{
  344. let puOrderIds = this.checkedList.map(order => Number(order.id));
  345. let { code } = await orderApi.close({ puOrderIds });
  346. if (code === 200) {
  347. this.handleRefreshList();
  348. }
  349. })
  350. } catch (error) { }
  351. },
  352. // 付款协议
  353. async handlePaymentRequest(){
  354. // name:工号
  355. try {
  356. let {code,msg} = await orderApi.payRequest();
  357. if(code == 200){
  358. msg.replace(/\/n/g,'');
  359. let url = `uclient://start/http://172.16.100.2:8081?ssoKey=${msg}&uiloader=nc.uap.lfw.applet.PortalUILoader&nodeId=40040407`
  360. window.location.href = url;
  361. }
  362. } catch (error) {}
  363. },
  364. // 退货
  365. async handlePurchaseReturn(){
  366. const { id } = this.checkedList[0];
  367. const { setVisible, fetchStorage } = this.$refs.PurchaseReturnDrawerRef;
  368. await setVisible(true);
  369. await fetchStorage(id);
  370. },
  371. // 主表Select框
  372. handleSelect(selection, row) {
  373. this.checkedList = selection;
  374. console.log(this.checkedList, 'this.checkedList');
  375. },
  376. handleSelectionChange(selection){
  377. this.checkedList = selection;
  378. },
  379. // 子表Select框
  380. handleTabSelect(selection, row){
  381. this.checkedTabList = selection;
  382. console.log(this.checkedTabList, 'this.checkedTabList');
  383. },
  384. handleTabSelectionChange(selection){
  385. this.checkedTabList = selection;
  386. },
  387. // 保留两位小数,补位
  388. keepTwoDecimalStr(num) {
  389. if(num){
  390. const result = Number(num.toString().match(/^\d+(?:\.\d{0,2})?/));
  391. let s = result.toString();
  392. let rs = s.indexOf('.');
  393. if (rs < 0) {
  394. rs = s.length;
  395. s += '.';
  396. }
  397. while (s.length <= rs + 2) {
  398. s += '0';
  399. }
  400. return s;
  401. }else{
  402. return '';
  403. }
  404. },
  405. judgeIsOption(type,source){
  406. // status: 0=自由态,1=审批中,2=已审核,3=已驳回 4=提交中
  407. // source: 1=自动协议直采,2=协议直采,3=手工
  408. // isEnd:整单关闭标识
  409. switch(type){
  410. case 'edit':
  411. return (source.status == '0' || source.status == '3') && source.isEnd === 'N';
  412. case 'revise':
  413. return source.status == '2' && source.isEnd === 'N';
  414. case 'del':
  415. return (source.status == '0' || source.status == '3') && source.source == '3' && source.isEnd === 'N';
  416. case 'submit':
  417. return (source.status == '0' || source.status == '3') && source.isEnd === 'N';
  418. case 'allClose':
  419. return source.status == 0 && source.isEnd === 'N';
  420. case 'return':
  421. return source.source != 3 && source.isEnd === 'N' &&
  422. (source.status == 0 || source.status == 3);
  423. default:
  424. return false;
  425. }
  426. }
  427. }
  428. };
  429. </script>
  430. <template>
  431. <el-card
  432. v-loading="loading"
  433. style="width: calc(100% - 24px); height: 100%; margin: 10px;padding: 10px;"
  434. :body-style="{ padding: 0 }"
  435. >
  436. <SeeDrawer ref="seeDrawerRef"></SeeDrawer>
  437. <AddDrawer ref="addDrawerFef" @close="handleRefreshList"></AddDrawer>
  438. <EditDrawer ref="editDrawerRef" @close="handleRefreshList"></EditDrawer>
  439. <PurchaseReturnDrawer ref="PurchaseReturnDrawerRef" @close="handleRefreshList"></PurchaseReturnDrawer>
  440. <el-super-search
  441. v-model="params"
  442. :size="'mini'"
  443. :dict="dict"
  444. :columns="searchColumns"
  445. @reset="handleResetList"
  446. @submit="handleQueryList"
  447. ></el-super-search>
  448. <!-- 操作 -->
  449. <el-row :gutter="24" type="flex" justify="end" style="margin: 20px 0;">
  450. <el-col :span="24" style="text-align: right;">
  451. <el-button size="mini" type="primary" @click="handleOpenAddDrawer"
  452. v-hasPermi="['material:order:add']">新增</el-button>
  453. <el-button-group style="margin-left: 10px">
  454. <el-button type="primary" size="mini" :disabled="checkedList.length != 1" @click="handleCopy">复制</el-button>
  455. <el-button type="primary" size="mini" @click="handleBatchSubmit">批量提交</el-button>
  456. </el-button-group>
  457. <el-button-group style="margin-left: 10px" :key="checkedList.length + 1">
  458. <el-button type="primary" size="mini" @click="handleAllReturn" :disabled="judgeIsAllReturn()">整单退回</el-button>
  459. <el-button type="primary" size="mini" @click="handleAllClose" :disabled="judgeIsAllClose()">整单关闭</el-button>
  460. </el-button-group>
  461. <el-button-group style="margin:0 10px">
  462. <!-- <el-button size="mini"
  463. :disabled="!(checkedList.length == 1 && checkedList[0].deliveryStatus == '0')"
  464. :key="checkedList.length"
  465. @click="handlePurchaseReturn"
  466. >采购退货</el-button> -->
  467. <el-button type="primary" size="mini" @click="handlePaymentRequest">付款申请</el-button>
  468. <el-button
  469. type="primary"
  470. size="mini"
  471. @click="handleDownload"
  472. >批量导出</el-button>
  473. </el-button-group>
  474. </el-col>
  475. </el-row>
  476. <div style="display: flex;height:420px;">
  477. <el-super-table
  478. class="purchaseTable"
  479. v-model="tableData"
  480. ref="purchaseTable"
  481. :dict="dict"
  482. :columns="tableColumns"
  483. :selectable="setSelectable"
  484. index
  485. checkbox
  486. pagination
  487. :page="page"
  488. convenitentOperation
  489. @pagination="fetchList(params, page)"
  490. @row-dblclick="handleOpenSeeDrawer"
  491. @row-click="handleDetailsData"
  492. @selection-change="handleSelectionChange"
  493. @select="handleSelect"
  494. >
  495. <el-table-column fixed="right" label="操作" width="120">
  496. <template slot-scope="scope">
  497. <el-button
  498. v-if="judgeIsOption('revise',scope.row)"
  499. type="text"
  500. size="small"
  501. @click.stop="handleOpenEditDrawer(scope.row)"
  502. v-hasPermi="['material:order:edit']">
  503. 修订
  504. </el-button>
  505. <el-button
  506. v-if="judgeIsOption('edit',scope.row)"
  507. type="text"
  508. size="small"
  509. @click.stop="handleOpenEditDrawer(scope.row)"
  510. v-hasPermi="['material:order:edit']">
  511. 编辑
  512. </el-button>
  513. <!-- 0=自由态,1=审批中,2=已审核,3=已驳回 4=提交中-->
  514. <el-button
  515. v-if="judgeIsOption('del',scope.row)"
  516. type="text"
  517. size="small"
  518. @click.stop="handleDeleteList(scope.row)"
  519. v-hasPermi="['material:order:remove']"
  520. >删除</el-button>
  521. <el-button
  522. v-if="judgeIsOption('submit',scope.row)"
  523. type="text"
  524. size="mini"
  525. v-hasPermi="['material:order:toOa']"
  526. @click.stop="handleSubmit(scope.row)"
  527. >提交</el-button>
  528. <el-button
  529. v-if="scope.row.flowId && scope.row.flowId !== ''"
  530. type="text"
  531. size="mini"
  532. @click.stop="jumpFlow(scope.row)"
  533. >流程跳转</el-button>
  534. </template>
  535. </el-table-column>
  536. </el-super-table>
  537. </div>
  538. <div style="position: relative; padding-top: 10px;" v-loading="tabLoading">
  539. <el-row style="position: absolute; top: 30px; right: 20px;z-index: 10;">
  540. <el-button
  541. size="mini"
  542. @click="handleLineReturn"
  543. :disabled="judgeIsLineReturn()"
  544. >行退回</el-button>
  545. </el-row>
  546. <el-tabs
  547. v-model="tabName"
  548. @tab-click="handleTabClick"
  549. style="width: 100%;padding: 20px 10px;">
  550. <el-tab-pane
  551. v-for="(column, index) in tabColumns"
  552. :key="index"
  553. :label="column.title"
  554. :name="column.key"
  555. >
  556. <div style="height:580px;display:flex">
  557. <el-super-table
  558. v-model="tabTableDatas[column.key]"
  559. :ref="column.key"
  560. :dict="dict"
  561. :columns="column.tableColumns"
  562. :selectable="setTabSelectable"
  563. :checkbox="setTabSelectable()"
  564. convenitentOperation
  565. @select="handleTabSelect"
  566. @selection-change="handleTabSelectionChange"
  567. >
  568. </el-super-table>
  569. </div>
  570. </el-tab-pane>
  571. </el-tabs>
  572. </div>
  573. </el-card>
  574. </template>
  575. <style lang="scss">
  576. </style>