index.vue 17 KB

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