index.vue 21 KB

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