index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  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. setSelectable(){
  84. return true
  85. },
  86. setTabSelectable(){
  87. if(this.tabName === 'puOrderItemList'){
  88. return true
  89. }
  90. return false
  91. },
  92. // 刷新操作
  93. handleRefreshList() {
  94. this.page.pageNum = 1;
  95. this.page.pageSize = 10;
  96. this.checkedList = [];
  97. this.checkedTabList = [];
  98. this.primaryResource = {};
  99. this.fetchList(this.params, this.page);
  100. },
  101. // 查询操作
  102. handleQueryList() {
  103. let {date} = this.params;
  104. this.params.startDate = date ? date[0] :'';
  105. this.params.endDate = date ? date[1] : '';
  106. this.fetchList(this.params, this.page);
  107. },
  108. // 重置操作
  109. handleResetList() {
  110. this.page.pageNum = 1;
  111. this.page.pageSize = 10;
  112. this.params = initParams(SearchColumns);
  113. this.fetchList(this.params, this.page);
  114. },
  115. handleTabClick() { },
  116. // 新增
  117. handleOpenAddDrawer(copyVal) {
  118. const { setVisible, setCopyParams } = this.$refs.addDrawerFef;
  119. setVisible(true,(copyVal.id && copyVal.id != '') ? true :false);
  120. copyVal.id && copyVal.id != '' && setCopyParams(copyVal.id);
  121. },
  122. // 复制
  123. handleCopy() {
  124. this.handleOpenAddDrawer(this.checkedList[0]);
  125. },
  126. // 查看
  127. async handleOpenSeeDrawer(row) {
  128. window.clearInterval(this.timeOut);
  129. const { id } = row;
  130. const { setVisible, fetchItem } = this.$refs.seeDrawerRef;
  131. await setVisible(true);
  132. await fetchItem(id);
  133. },
  134. // 编辑、修订
  135. async handleOpenEditDrawer(row) {
  136. const { id } = row;
  137. const { setVisible, fetchItem } = this.$refs.editDrawerRef;
  138. await setVisible(true);
  139. await fetchItem(id);
  140. },
  141. // 获取子表信息
  142. handleDetailsData(row) {
  143. window.clearTimeout(this.timeOut);
  144. this.timeOut = setTimeout(async () =>{
  145. try {
  146. this.tabLoading = true;
  147. this.primaryResource = row;
  148. this.checkedTabList = [];
  149. const { code, msg, data } = await orderApi.details(row.id);
  150. if (code === 200) {
  151. // 物料信息:puOrderItemList 执行结果:puOrderExecuteList
  152. for (const key in this.tabTableDatas) {
  153. this.tabTableDatas[key] = data[key];
  154. }
  155. }
  156. } catch (err) {}
  157. finally{
  158. this.tabLoading = false;
  159. }
  160. },this.timer)
  161. },
  162. // 操作提示弹窗
  163. handleConfirmTips(success){
  164. this.$confirm('是否继续此操作?', '提示', {
  165. confirmButtonText: '确定',
  166. cancelButtonText: '取消',
  167. type: 'warning'
  168. }).then(() => {
  169. success();
  170. }).catch(() => {
  171. });
  172. },
  173. // 删除操作
  174. handleDeleteList(row) {
  175. try {
  176. this.loading = true;
  177. this.handleConfirmTips(async()=>{
  178. const { id } = row;
  179. const { code } = await orderApi.remove(id);
  180. if (code === 200) {
  181. this.handleRefreshList();
  182. }
  183. })
  184. } catch (err) {
  185. //
  186. } finally {
  187. this.loading = false;
  188. }
  189. },
  190. // 批量提交
  191. handleBatchSubmit(){
  192. let inconformity = this.checkedList.filter(row => !((row.status == '0' || row.status == '3') && row.isEnd === 'N'));
  193. if(!inconformity.length && this.checkedList.length){
  194. let puOrderIds = this.checkedList.map( item => Number(item.id));
  195. this.fetchSubmit(puOrderIds);
  196. }else{
  197. this.$notify({
  198. title: '警告',
  199. message: '当前选中存在不满足提交条件的数据!',
  200. type: 'warning'
  201. });
  202. }
  203. },
  204. // 提交
  205. handleSubmit(row) {
  206. let puOrderIds = [Number(row.id)];
  207. this.fetchSubmit(puOrderIds);
  208. },
  209. fetchSubmit(puOrderIds){
  210. try {
  211. this.handleConfirmTips(async()=>{
  212. let { code } = await orderApi.submit({ puOrderIds});
  213. if (code == 200) {
  214. this.handleRefreshList();
  215. }
  216. })
  217. } catch (error) {}
  218. },
  219. // 判断“整单退回”按钮
  220. judgeIsAllReturn() {
  221. if (this.checkedList.length == 1) {
  222. // 非手工、状态:自由/驳回
  223. if (this.judgeIsOption('return',this.checkedList[0])) {
  224. // if (this.checkedList[0].source != 3 &&
  225. // (this.checkedList[0].status == 0 || this.checkedList[0].status == 3)
  226. // ) {
  227. return false
  228. }
  229. }
  230. return true;
  231. },
  232. // 整单退回
  233. handleAllReturn() {
  234. this.handleReturn(this.checkedList[0].id,[]);
  235. },
  236. // 判断“行退回”按钮
  237. judgeIsLineReturn() {
  238. if (this.checkedTabList.length == 1) {
  239. // 主信息:非手工、状态:自由/驳回
  240. if(this.judgeIsOption('return',this.primaryResource)){
  241. // if(this.primaryResource.source != 3 &&
  242. // (this.primaryResource.status == 0 || this.primaryResource.status == 3) ){
  243. return false
  244. }
  245. }
  246. return true;
  247. },
  248. // 行退回
  249. handleLineReturn(){
  250. let ids = this.checkedTabList.map(checked => checked.id);
  251. console.log(ids,'行退回ids');
  252. this.handleReturn(this.primaryResource.id,ids);
  253. },
  254. // 退回接口
  255. handleReturn(id,documentIds){
  256. this.$prompt('请输入退回原因', '提示', {
  257. confirmButtonText: '确定',
  258. cancelButtonText: '取消',
  259. inputPattern: /\s*\S+?/,
  260. inputErrorMessage: '退回原因不能为空'
  261. }).then(async ({ value }) => {
  262. let data = {
  263. id:Number(id),
  264. documentIds:documentIds.map(ids =>Number(ids)),
  265. baskCause: value,
  266. };
  267. console.log(data);
  268. try {
  269. let { code, msg } = await orderApi.documentsReturn(data);
  270. if (code === 200) {
  271. this.handleRefreshList();
  272. }
  273. } catch (error) {
  274. console.log(error,'error------------');
  275. }
  276. }).catch(() => { });
  277. },
  278. // 判断是否满足整单关闭
  279. judgeIsAllClose() {
  280. if (this.checkedList.length == 1) {
  281. // if (this.checkedList[0].status == 0) {
  282. if (this.judgeIsOption('allClose',this.checkedList[0])) {
  283. // 未审批状态下整单关闭
  284. return false
  285. }
  286. }
  287. return true;
  288. },
  289. // 整单关闭
  290. handleAllClose() {
  291. // 未审批状态下整单关闭
  292. try {
  293. this.handleConfirmTips(async() =>{
  294. let puOrderIds = this.checkedList.map(order => Number(order.id));
  295. let { code } = await orderApi.close({ puOrderIds });
  296. if (code === 200) {
  297. this.handleRefreshList();
  298. }
  299. })
  300. } catch (error) { }
  301. },
  302. // 付款协议
  303. async handlePaymentRequest(){
  304. // name:工号
  305. try {
  306. let {code,msg} = await orderApi.payRequest();
  307. if(code == 200){
  308. msg.replace(/\/n/g,'');
  309. let url = `uclient://start/http://172.16.100.2:8081?ssoKey=${msg}&uiloader=nc.uap.lfw.applet.PortalUILoader&nodeId=40040407`
  310. window.location.href = url;
  311. }
  312. } catch (error) {}
  313. },
  314. // 退货
  315. async handlePurchaseReturn(){
  316. const { id } = this.checkedList[0];
  317. const { setVisible, fetchStorage } = this.$refs.PurchaseReturnDrawerRef;
  318. await setVisible(true);
  319. await fetchStorage(id);
  320. },
  321. // 主表Select框
  322. handleSelect(selection, row) {
  323. this.checkedList = selection;
  324. console.log(this.checkedList, 'this.checkedList');
  325. },
  326. // 子表Select框
  327. handleTabSelect(selection, row){
  328. this.checkedTabList = selection;
  329. console.log(this.checkedTabList, 'this.checkedTabList');
  330. },
  331. // 保留两位小数,补位
  332. keepTwoDecimalStr(num) {
  333. if(num){
  334. const result = Number(num.toString().match(/^\d+(?:\.\d{0,2})?/));
  335. let s = result.toString();
  336. let rs = s.indexOf('.');
  337. if (rs < 0) {
  338. rs = s.length;
  339. s += '.';
  340. }
  341. while (s.length <= rs + 2) {
  342. s += '0';
  343. }
  344. return s;
  345. }else{
  346. return '';
  347. }
  348. },
  349. judgeIsOption(type,source){
  350. // status: 0=自由态,1=审批中,2=已审核,3=已驳回 4=提交中
  351. // source: 1=自动协议直采,2=协议直采,3=手工
  352. // isEnd:整单关闭标识
  353. switch(type){
  354. case 'edit':
  355. return (source.status == '0' || source.status == '3') && source.isEnd === 'N';
  356. case 'revise':
  357. return source.status == '2' && source.isEnd === 'N';
  358. case 'del':
  359. return (source.status == '0' || source.status == '3') && source.source == '3' && source.isEnd === 'N';
  360. case 'submit':
  361. return (source.status == '0' || source.status == '3') && source.isEnd === 'N';
  362. case 'allClose':
  363. return source.status == 0 && source.isEnd === 'N';
  364. case 'return':
  365. return source.source != 3 && source.isEnd === 'N' &&
  366. (source.status == 0 || source.status == 3);
  367. default:
  368. return false;
  369. }
  370. }
  371. }
  372. };
  373. </script>
  374. <template>
  375. <el-card
  376. v-loading="loading"
  377. style="width: calc(100% - 24px); height: 100%; margin: 10px;padding: 10px;"
  378. :body-style="{ padding: 0 }"
  379. >
  380. <SeeDrawer ref="seeDrawerRef"></SeeDrawer>
  381. <AddDrawer ref="addDrawerFef" @close="handleRefreshList"></AddDrawer>
  382. <EditDrawer ref="editDrawerRef" @close="handleRefreshList"></EditDrawer>
  383. <PurchaseReturnDrawer ref="PurchaseReturnDrawerRef" @close="handleRefreshList"></PurchaseReturnDrawer>
  384. <el-super-search
  385. v-model="params"
  386. :size="'mini'"
  387. :dict="dict"
  388. :columns="searchColumns"
  389. @reset="handleResetList"
  390. @submit="handleQueryList"
  391. ></el-super-search>
  392. <!-- 操作 -->
  393. <el-row :gutter="24" type="flex" justify="end" style="margin: 20px 0;">
  394. <el-col :span="24" style="text-align: right;">
  395. <el-button size="mini" type="primary" @click="handleOpenAddDrawer"
  396. v-hasPermi="['material:order:add']">新增</el-button>
  397. <el-button-group style="margin-left: 10px">
  398. <el-button type="primary" size="mini" :disabled="checkedList.length != 1" @click="handleCopy">复制</el-button>
  399. <el-button type="primary" size="mini" @click="handleBatchSubmit">批量提交</el-button>
  400. </el-button-group>
  401. <el-button-group style="margin-left: 10px" :key="checkedList.length + 1">
  402. <el-button type="primary" size="mini" @click="handleAllReturn" :disabled="judgeIsAllReturn()">整单退回</el-button>
  403. <el-button type="primary" size="mini" @click="handleAllClose" :disabled="judgeIsAllClose()">整单关闭</el-button>
  404. </el-button-group>
  405. <el-button-group style="margin:0 10px">
  406. <!-- <el-button size="mini"
  407. :disabled="!(checkedList.length == 1 && checkedList[0].deliveryStatus == '0')"
  408. :key="checkedList.length"
  409. @click="handlePurchaseReturn"
  410. >采购退货</el-button> -->
  411. <el-button type="primary" size="mini" @click="handlePaymentRequest">付款申请</el-button>
  412. </el-button-group>
  413. </el-col>
  414. </el-row>
  415. <el-super-table
  416. v-model="tableData"
  417. max-height="480"
  418. :dict="dict"
  419. :columns="tableColumns"
  420. :selectable="setSelectable"
  421. checkbox
  422. pagination
  423. :page="page"
  424. :iconOperation="false"
  425. @pagination="fetchList(params, page)"
  426. @row-dblclick="handleOpenSeeDrawer"
  427. @row-click="handleDetailsData"
  428. @select="handleSelect"
  429. >
  430. <!-- <el-table-column type="selection" width="45" fixed></el-table-column>
  431. <el-table-column type="index" width="50" label="序号"></el-table-column> -->
  432. <el-table-column fixed="right" label="操作" width="120">
  433. <template slot-scope="scope">
  434. <el-button
  435. v-if="judgeIsOption('revise',scope.row)"
  436. type="text"
  437. size="small"
  438. @click.stop="handleOpenEditDrawer(scope.row)"
  439. v-hasPermi="['material:order:edit']">
  440. 修订
  441. </el-button>
  442. <el-button
  443. v-if="judgeIsOption('edit',scope.row)"
  444. type="text"
  445. size="small"
  446. @click.stop="handleOpenEditDrawer(scope.row)"
  447. v-hasPermi="['material:order:edit']">
  448. 编辑
  449. </el-button>
  450. <!-- 0=自由态,1=审批中,2=已审核,3=已驳回 4=提交中-->
  451. <el-button
  452. v-if="judgeIsOption('del',scope.row)"
  453. type="text"
  454. size="small"
  455. @click.stop="handleDeleteList(scope.row)"
  456. v-hasPermi="['material:order:remove']"
  457. >删除</el-button>
  458. <el-button
  459. v-if="judgeIsOption('submit',scope.row)"
  460. type="text"
  461. size="mini"
  462. v-hasPermi="['material:order:toOa']"
  463. @click.stop="handleSubmit(scope.row)"
  464. >提交</el-button>
  465. </template>
  466. </el-table-column>
  467. </el-super-table>
  468. <!-- <pagination
  469. v-show="page.total>0"
  470. :total="page.total"
  471. :page.sync="page.pageNum"
  472. :limit.sync="page.pageSize"
  473. :page-sizes="[10,20,50,100,500,1000]"
  474. @pagination="fetchList(params, page)"
  475. />
  476. -->
  477. <div style="position: relative; padding-top: 10px;" v-loading="tabLoading">
  478. <el-row style="position: absolute; top: 30px; right: 20px;z-index: 10;">
  479. <el-button
  480. size="mini"
  481. @click="handleLineReturn"
  482. :disabled="judgeIsLineReturn()"
  483. >行退回</el-button>
  484. </el-row>
  485. <el-tabs v-model="tabName" @tab-click="handleTabClick" style="width: 100%;padding: 20px 10px">
  486. <el-tab-pane
  487. v-for="(column, index) in tabColumns"
  488. :key="index"
  489. :label="column.title"
  490. :name="column.key"
  491. >
  492. <el-super-table
  493. v-model="tabTableDatas[column.key]"
  494. max-height="200"
  495. :dict="dict"
  496. :columns="column.tableColumns"
  497. :selectable="setTabSelectable"
  498. :checkbox="setTabSelectable()"
  499. :iconOperation="false"
  500. @select="handleTabSelect"
  501. >
  502. <!-- <el-table-column
  503. v-if=" tabName === 'puOrderItemList'"
  504. type="selection"
  505. width="45"
  506. ></el-table-column> -->
  507. <!-- <el-table-column type="index" width="50" label="序号"></el-table-column> -->
  508. </el-super-table>
  509. </el-tab-pane>
  510. </el-tabs>
  511. </div>
  512. </el-card>
  513. </template>