index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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. initLayout,
  8. initPageSizes,
  9. initParams,
  10. initColumns,
  11. initDicts,
  12. } from "@/utils/init";
  13. export default {
  14. name: "PuchaseOrder",
  15. dicts: initDicts(SelectColumns),
  16. components: {
  17. AddDrawer: () => import('./add/index.vue'),
  18. SeeDrawer: () => import('./see/index.vue'),
  19. EditDrawer: () => import('./edit/index.vue'),
  20. },
  21. data() {
  22. const initTabColumns = () => TabColumns;
  23. return {
  24. loading: false,
  25. isSimpleSearch: true,
  26. pageSizes: initPageSizes(),
  27. layout: initLayout(),
  28. page: initPage(),
  29. searchColumns: SearchColumns,
  30. params: initParams(SearchColumns),
  31. tableColumns: TableColumns,
  32. tableData: [],
  33. tabColumns: initTabColumns(),
  34. tabName: "puOrderItemList",
  35. tabTableDatas: {
  36. puOrderItemList: [],
  37. puOrderExecuteList: [],
  38. },
  39. checkedList: [],
  40. };
  41. },
  42. computed: {
  43. showSearchColumns() {
  44. return this.isSimpleSearch
  45. ? this.searchColumns.slice(0, 4)
  46. : this.searchColumns;
  47. },
  48. },
  49. created() {
  50. this.fetchList(this.params, this.page);
  51. console.log("Vue", this);
  52. },
  53. methods: {
  54. async fetchList(params, page) {
  55. try {
  56. this.loading = true;
  57. // const { pageNum, pageSize } = page;
  58. const { code, msg, rows, total } = await orderApi.list(params, page);
  59. if (code === 200) {
  60. this.page.total = total;
  61. this.tableData = rows;
  62. }
  63. } catch (err) {
  64. //
  65. } finally {
  66. this.loading = false;
  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. handleSizeChange(prop) {
  77. this.page.pageSize = prop;
  78. this.fetchList(this.params, this.page);
  79. },
  80. // 当前页变
  81. handleCurrentChange(prop) {
  82. this.page.pageNum = prop;
  83. this.fetchList(this.params, this.page);
  84. },
  85. // 刷新操作
  86. handleRefreshList() {
  87. this.fetchList(this.params, this.page);
  88. },
  89. // 查询操作
  90. handleQueryList() {
  91. this.fetchList(this.params, this.page);
  92. },
  93. // 重置操作
  94. handleResetList() {
  95. this.page = initPage();
  96. this.params = initParams(SearchColumns);
  97. this.fetchList(this.params, this.page);
  98. },
  99. handleTabClick() { },
  100. // 新增
  101. handleOpenAddDrawer(copyVal) {
  102. const { setVisible, setCopyParams } = this.$refs.addDrawerFef;
  103. setVisible(true);
  104. copyVal.id && copyVal.id != '' && setCopyParams(copyVal.id);
  105. },
  106. // 复制
  107. handleCopy() {
  108. // let rowDetails = {
  109. // ... this.checkedList[0],
  110. // id: '',
  111. // code: '',
  112. // status: '0',
  113. // source: '3',
  114. // };
  115. this.handleOpenAddDrawer(this.checkedList[0]);
  116. },
  117. // 查看
  118. async handleOpenSeeDrawer(row) {
  119. const { id } = row;
  120. const { setVisible, fetchItem } = this.$refs.seeDrawerFef;
  121. await setVisible(true);
  122. await fetchItem(id);
  123. },
  124. // 编辑、修订
  125. async handleOpenEditDrawer(row) {
  126. const { id } = row;
  127. const { setVisible, fetchItem } = this.$refs.editDrawerFef;
  128. await setVisible(true);
  129. await fetchItem(id);
  130. },
  131. // 获取子表信息
  132. async handleDetailsData(row) {
  133. try {
  134. const { code, msg, data } = await orderApi.details(row.id);
  135. if (code === 200) {
  136. // 物料信息:puOrderItemList 执行结果:puOrderExecuteList
  137. for (const key in this.tabTableDatas) {
  138. this.tabTableDatas[key] = data[key];
  139. }
  140. }
  141. } catch (err) {
  142. //
  143. } finally {
  144. // this.loading = false;
  145. }
  146. },
  147. // 删除操作
  148. async handleDeleteList(row) {
  149. try {
  150. this.loading = true;
  151. const { id } = row;
  152. console.log(id, 'id');
  153. const { code, msg } = await orderApi.remove(id);
  154. if (code === 200) {
  155. this.fetchList(this.params, this.page);
  156. }
  157. } catch (err) {
  158. //
  159. } finally {
  160. this.loading = false;
  161. }
  162. },
  163. // 提交
  164. async handleSubmit(row) {
  165. try {
  166. let { code } = await orderApi.submit({ puOrderId: row.id });
  167. if (code == 200) {
  168. this.fetchList(this.params, this.page);
  169. }
  170. } catch (error) {
  171. } finally {
  172. }
  173. },
  174. // 判断“退回”按钮
  175. judgeIsAllSendBack() {
  176. if (this.checkedList.length == 1) {
  177. // 非手工、状态非审批通过
  178. if (this.checkedList[0].source != 3 && (this.checkedList[0].status == 0 || this.checkedList[0].status == 3)) {
  179. return false
  180. }
  181. }
  182. return true;
  183. },
  184. // 整单退回
  185. handleAllSendBack() {
  186. let data = {
  187. id: this.checkedList[0].id,
  188. documentIds: [],
  189. baskCause: ''
  190. }
  191. console.log(data);
  192. try {
  193. this.loading = true;
  194. let { code, msg } = orderApi.documentsReturn(data);
  195. } catch (error) {
  196. } finally {
  197. this.loading = false;
  198. }
  199. },
  200. // 判断是否满足整单关闭
  201. judgeIsAllClose() {
  202. if (this.checkedList.length == 1) {
  203. if (this.checkedList[0].status == 0) {
  204. // 未审批状态下整单关闭
  205. return false
  206. }
  207. }
  208. return true;
  209. },
  210. // 整单关闭
  211. async handleAllClose() {
  212. // 未审批状态下整单关闭
  213. try {
  214. this.loading = true;
  215. let puOrderIds = this.checkedList.map(order => {
  216. return order.id;
  217. })
  218. let { code } = await orderApi.close({ puOrderIds });
  219. if (code === 200) {
  220. this.fetchList(this.params, this.page);
  221. }
  222. } catch (error) {
  223. } finally {
  224. this.loading = false;
  225. }
  226. },
  227. handleSelect(selection, row) {
  228. this.checkedList = selection;
  229. console.log(this.checkedList, 'this.checkedList');
  230. },
  231. },
  232. };
  233. </script>
  234. <template>
  235. <el-card
  236. v-loading="loading"
  237. style="width: calc(100% - 24px); height: 100%; margin: 10px"
  238. :body-style="{ padding: 0 }"
  239. >
  240. <SeeDrawer ref="seeDrawerFef"></SeeDrawer>
  241. <AddDrawer ref="addDrawerFef" @close="handleRefreshList"></AddDrawer>
  242. <EditDrawer ref="editDrawerFef" @close="handleRefreshList"></EditDrawer>
  243. <el-form
  244. size="mini"
  245. label-position="right"
  246. label-width="100px"
  247. :model="params"
  248. style="padding: 20px 0 0 0"
  249. >
  250. <el-row :gutter="24" style="display:flex; flex-wrap: wrap;">
  251. <el-col :span="20">
  252. <el-row :gutter="20">
  253. <el-col
  254. v-for="column in showSearchColumns"
  255. :key="column.title"
  256. :xl="6" :lg="6" :md="8" :sm="12" :xs="24"
  257. >
  258. <el-form-item :prop="column.key" :label="column.title">
  259. <el-input v-model="params[column.key]" :placeholder="column.placeholder"></el-input>
  260. </el-form-item>
  261. </el-col>
  262. </el-row>
  263. </el-col>
  264. <el-col :span="4" style="text-align: right; padding-right: 40px">
  265. <el-button type="primary" size="mini" @click="handleQueryList"
  266. v-hasPermi="['material:order:query']">搜索</el-button>
  267. <el-button size="mini" @click="handleResetList">重置</el-button>
  268. </el-col>
  269. </el-row>
  270. </el-form>
  271. <!-- <el-divider>
  272. <i :class="isSimpleSearch ? 'el-icon-arrow-down' : 'el-icon-arrow-up'" style="cursor: pointer"
  273. @click="handleSearchChange"></i>
  274. </el-divider> -->
  275. <!-- 操作 -->
  276. <el-row :gutter="24" style="padding: 0 20px">
  277. <!-- <el-col :span="6">123</el-col> -->
  278. <el-col :span="24" style="text-align: right;margin: 0 10px 0 0">
  279. <!-- <el-button-group style="margin-left: 10px"> -->
  280. <el-button size="mini" type="primary" plain @click="handleOpenAddDrawer"
  281. v-hasPermi="['material:order:add']">新增</el-button>
  282. <!-- </el-button-group> -->
  283. <el-button-group style="margin-left: 10px">
  284. <el-button size="mini" :disabled="checkedList.length != 1" @click="handleCopy">复制</el-button>
  285. </el-button-group>
  286. <el-button-group style="margin-left: 10px" :key="checkedList.length + 1">
  287. <el-button size="mini" @click="handleAllSendBack" :disabled="judgeIsAllSendBack()">整单退回</el-button>
  288. <el-button size="mini" @click="handleAllClose" :disabled="judgeIsAllClose()">整单关闭</el-button>
  289. </el-button-group>
  290. <el-button-group style="margin-left: 10px">
  291. <!-- <el-button size="mini">采购退货</el-button> -->
  292. <!-- <el-button size="mini">附件管理</el-button>
  293. <el-button size="mini">单据追溯</el-button> -->
  294. </el-button-group>
  295. </el-col>
  296. </el-row>
  297. <el-table
  298. @row-dblclick="handleOpenSeeDrawer"
  299. @row-click="handleDetailsData"
  300. :data="tableData"
  301. size="mini"
  302. highlight-current-row
  303. @select="handleSelect"
  304. height="450"
  305. style="width: 100%; margin: 20px 0 0 0"
  306. >
  307. <el-table-column type="selection" width="45"></el-table-column>
  308. <el-table-column type="index" width="50" label="序号"></el-table-column>
  309. <el-table-column
  310. v-for="(column, index) in tableColumns"
  311. :key="index"
  312. :prop="column.key"
  313. :label="column.title"
  314. :width="column.width || 180"
  315. :show-overflow-tooltip="column.showOverflowTooltip || true"
  316. >
  317. <template slot-scope="scope">
  318. <dict-tag v-if="column.referName"
  319. size="small"
  320. :value="scope.row[column.key]"
  321. :options="dict.type[column.referName]"
  322. />
  323. <el-checkbox v-else-if="column.inputType === 'Checkbox'"
  324. v-model="scope.row[column.key]"
  325. disabled
  326. true-label="Y"
  327. false-label="N"
  328. > </el-checkbox>
  329. <span v-else>{{ scope.row[column.key] }}</span>
  330. </template>
  331. </el-table-column>
  332. <el-table-column fixed="right" label="操作" width="120">
  333. <template slot-scope="scope">
  334. <!-- <el-button @click.stop="handleOpenSeeDrawer(scope.row)" type="text" size="small">查看</el-button> -->
  335. <el-button type="text" size="small" @click.stop="handleOpenEditDrawer(scope.row)"
  336. v-hasPermi="['material:order:edit']">
  337. {{ scope.row.status == '2' ? '修订' : '编辑' }}</el-button>
  338. <!-- 0=自由态,1=审批中,2=已审核,3=已驳回 4=提交中-->
  339. <el-button
  340. v-if="(scope.row.status == '0' || scope.row.status == '3') && scope.row.source == '3'"
  341. type="text"
  342. size="small"
  343. @click.stop="handleDeleteList(scope.row)"
  344. v-hasPermi="['material:order:remove']"
  345. >删除</el-button>
  346. <el-button
  347. v-if="scope.row.status == '0' || scope.row.status == '3'"
  348. type="text"
  349. size="mini"
  350. v-hasPermi="['material:order:toOa']"
  351. @click.stop="handleSubmit(scope.row)"
  352. >提交</el-button>
  353. </template>
  354. </el-table-column>
  355. </el-table>
  356. <el-pagination
  357. @size-change="handleSizeChange"
  358. @current-change="handleCurrentChange"
  359. :total="page.total"
  360. :page-sizes="pageSizes"
  361. :page-size="page.pageSize"
  362. :current-page="page.pageNum"
  363. hide-on-single-page
  364. :layout="layout"
  365. style="text-align: right;margin-top: 10px;"
  366. ></el-pagination>
  367. <el-tabs v-model="tabName" @tab-click="handleTabClick" style="width: 100%;padding: 20px 10px">
  368. <el-tab-pane
  369. v-for="(column, index) in tabColumns"
  370. :key="index"
  371. :label="column.title"
  372. :name="column.key"
  373. >
  374. <el-table :data="tabTableDatas[column.key]" style="width: 100%" highlight-current-row
  375. :height="tabTableDatas[column.key].length ? 300 : 100">
  376. <el-table-column type="index" width="50" label="序号"></el-table-column>
  377. <el-table-column
  378. v-for="(cColumn, cIndex) in column.tableColumns"
  379. :key="cIndex"
  380. :prop="cColumn.key"
  381. :label="cColumn.title"
  382. :width="cColumn.width || 180"
  383. :show-overflow-tooltip="cColumn.showOverflowTooltip || true"
  384. >
  385. <template slot-scope="scope">
  386. <dict-tag v-if="cColumn.referName"
  387. size="small"
  388. :value="scope.row[cColumn.key]"
  389. :options="dict.type[cColumn.referName]"
  390. />
  391. <el-checkbox v-else-if="cColumn.inputType === 'Checkbox'"
  392. v-model="scope.row[cColumn.key]"
  393. disabled
  394. true-label="Y"
  395. false-label="N"
  396. ></el-checkbox>
  397. <span v-else>{{ scope.row[cColumn.key] }}</span>
  398. </template>
  399. </el-table-column>
  400. </el-table>
  401. </el-tab-pane>
  402. </el-tabs>
  403. </el-card>
  404. </template>