index.vue 16 KB

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