index.vue 18 KB

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