index.vue 21 KB

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