index.vue 13 KB

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