index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. el-col
  2. <script>
  3. import { TableColumns, SearchColumns } from "./column";
  4. import { LIST, SHUTDOWN } from "@/api/business/purchase/task";
  5. import {
  6. initPage,
  7. initDicts,
  8. initLayout,
  9. initParams,
  10. initPageSizes,
  11. } from "@/utils/init";
  12. export default {
  13. name: "PuchaseTask",
  14. dicts: [...initDicts(TableColumns), ...initDicts(SearchColumns)],
  15. components: {
  16. SeeDialog: () => import("./see/index.vue"),
  17. FirstDirectDialog: () => import("./first-direct/index.vue"),
  18. DocReturnDialog: () => import("./documents-return/index.vue"),
  19. ModifyBuyerDialog: () => import("./modify-buyer/index.vue"),
  20. },
  21. data() {
  22. return {
  23. size: "mini",
  24. loading: false,
  25. searchColumns: SearchColumns,
  26. params: initParams(SearchColumns),
  27. tableData: [],
  28. selectData: [],
  29. tableColumns: TableColumns,
  30. page: { pageNum: 1, pageSize: 10, total: 0 },
  31. };
  32. },
  33. computed: {},
  34. watch: {},
  35. created() {
  36. this.queryList(this.params, this.page);
  37. },
  38. methods: {
  39. //
  40. async fetchList(prop, page) {
  41. try {
  42. this.loading = true;
  43. const { pageNum, pageSize } = page;
  44. const { code, msg, rows, total } = await LIST(
  45. { ...prop },
  46. { pageNum, pageSize, isAsc: "desc", orderByColumn: "createTime" }
  47. );
  48. if (code === 200) {
  49. this.tableData = rows;
  50. this.page.total = total;
  51. this.$notify.success({ title: msg });
  52. } else {
  53. this.$notify.warning({ title: msg });
  54. }
  55. } catch (err) {
  56. //
  57. } finally {
  58. this.loading = false;
  59. }
  60. },
  61. // 查询操作
  62. queryList(prop, page) {
  63. const { date } = prop;
  64. prop.endDate = date[1];
  65. prop.startDate = date[0];
  66. this.fetchList({ ...prop, date: undefined }, page);
  67. },
  68. // 重置操作
  69. resetList() {
  70. this.page = initPage();
  71. this.params = initParams(SearchColumns);
  72. this.queryList(this.params, this.page);
  73. },
  74. // 页大小变
  75. sizeChange(prop) {
  76. this.page.pageSize = prop;
  77. this.queryList(this.params, this.page);
  78. },
  79. // 当前页变
  80. currentChange(prop) {
  81. this.page.pageNum = prop;
  82. this.queryList(this.params, this.page);
  83. },
  84. // 选择行
  85. selectionChange(prop) {
  86. this.selectData = prop;
  87. },
  88. // 行关闭
  89. async shutDown(prop) {
  90. try {
  91. this.loading = true;
  92. const { demandItemId } = prop;
  93. const { code, msg } = await SHUTDOWN(demandItemId);
  94. if (code === 200) {
  95. this.$notify.success({ title: msg });
  96. await this.queryList(this.params, this.page);
  97. } else {
  98. this.$notify.warning({ title: msg });
  99. }
  100. } catch (err) {
  101. //
  102. } finally {
  103. this.loading = false;
  104. }
  105. },
  106. // 退回需求
  107. async openDocumentsReturnDialog(prop) {
  108. const { open } = this.$refs.DocReturnDialog;
  109. await open(prop);
  110. },
  111. // 转派
  112. async openModifyBuyerDialog(prop) {
  113. const { id } = prop;
  114. const { open } = this.$refs.ModifyBuyerDialog;
  115. await open(id);
  116. },
  117. // 打开查看drawer
  118. async openSeeDialog(prop) {
  119. const { id } = prop;
  120. const { open } = this.$refs.SeeDialog;
  121. await open(id);
  122. },
  123. // 打开首次直采drawer
  124. async openFristDirectDialog(prop) {
  125. const { open } = this.$refs.FirstDirectDialog;
  126. await open(prop);
  127. },
  128. // 导出
  129. async useExport(prop, page) {
  130. const { pageNum, pageSize } = page;
  131. this.download(
  132. "pu/order/generate/export",
  133. { ...prop, pageNum, pageSize },
  134. `KONG_${new Date().getTime()}.xlsx`
  135. );
  136. },
  137. },
  138. };
  139. </script>
  140. <template>
  141. <el-card
  142. v-loading="loading"
  143. style="
  144. width: calc(100% - 20px);
  145. height: 100%;
  146. margin: 10px;
  147. padding: 0 20px 20px 0;
  148. "
  149. :body-style="{ padding: 0 }"
  150. >
  151. <see-dialog ref="SeeDialog"></see-dialog>
  152. <first-direct-dialog
  153. ref="FirstDirectDialog"
  154. @success="resetList"
  155. ></first-direct-dialog>
  156. <doc-return-dialog
  157. ref="DocReturnDialog"
  158. @success="resetList"
  159. ></doc-return-dialog>
  160. <modify-buyer-dialog
  161. ref="ModifyBuyerDialog"
  162. @success="resetList"
  163. ></modify-buyer-dialog>
  164. <el-backtop target=".el-scrollbar__wrap"></el-backtop>
  165. <el-form
  166. :size="size"
  167. :model="params"
  168. label-width="auto"
  169. label-position="right"
  170. style="padding: 20px 20px 0"
  171. @submit.native.prevent
  172. >
  173. <el-row :gutter="20" style="display: flex; flex-wrap: wrap">
  174. <el-col
  175. v-for="column in searchColumns"
  176. :key="column.title"
  177. :span="column.span || 6"
  178. >
  179. <el-form-item :prop="column.key" :label="column.title">
  180. <el-input
  181. v-if="column.inputType === 'Input'"
  182. v-model="params[column.key]"
  183. :disabled="column.disabled"
  184. :clearable="column.clearable"
  185. :placeholder="column.placeholder"
  186. style="width: 100%"
  187. ></el-input>
  188. <el-select
  189. v-if="column.inputType === 'Select'"
  190. v-model="params[column.key]"
  191. :disabled="column.disabled"
  192. :clearable="column.clearable"
  193. :placeholder="column.placeholder"
  194. style="width: 100%"
  195. >
  196. <el-option
  197. v-for="item in dict.type[column.referName]"
  198. :key="item.value"
  199. :label="item.label"
  200. :value="item.value"
  201. >
  202. </el-option>
  203. </el-select>
  204. <el-date-picker
  205. v-if="column.inputType === 'DatePicker'"
  206. v-model="params[column.key]"
  207. :type="column.type"
  208. :placeholder="column.placeholder"
  209. :value-format="column.valueFormat"
  210. :unlink-panels="column.unlinkPanels"
  211. :picker-options="column.pickerOptions"
  212. :range-separator="column.rangeSeparator"
  213. :end-placeholder="column.endPlaceholder"
  214. :start-placeholder="column.startPlaceholder"
  215. style="width: 100%"
  216. >
  217. </el-date-picker>
  218. <dr-popover-select
  219. v-if="column.inputType === 'PopoverSelect'"
  220. v-model="params[column.key]"
  221. :size="size"
  222. :source.sync="params"
  223. :title="column.title"
  224. :type="column.referName"
  225. :multiple="column.multiple"
  226. :readonly="column.readonly"
  227. :value-key="column.valueKey"
  228. :placeholder="column.placeholder"
  229. :data-mapping="column.dataMapping"
  230. :query-params="column.queryParams(params)"
  231. >
  232. </dr-popover-select>
  233. <dr-popover-tree-select
  234. v-if="column.inputType === 'PopoverTreeSelect'"
  235. v-model="params[column.key]"
  236. :source.sync="params"
  237. :title="column.title"
  238. :type="column.referName"
  239. :multiple="column.multiple"
  240. :show-key="column.showKey"
  241. :value-key="column.valueKey"
  242. :placeholder="column.placeholder"
  243. :data-mapping="column.dataMapping"
  244. :query-params="column.queryParams(params)"
  245. >
  246. </dr-popover-tree-select>
  247. </el-form-item>
  248. </el-col>
  249. <el-col :span="6">
  250. <el-form-item label-width="0">
  251. <el-button
  252. circle
  253. :size="size"
  254. icon="el-icon-search"
  255. @click="queryList(params, page)"
  256. ></el-button>
  257. <el-button
  258. circle
  259. :size="size"
  260. icon="el-icon-refresh"
  261. @click="resetList"
  262. ></el-button>
  263. </el-form-item>
  264. </el-col>
  265. </el-row>
  266. </el-form>
  267. <el-row :gutter="24" style="padding: 0 20px">
  268. <el-col :span="24">
  269. <el-button :size="size" @click="useExport(params, page)">
  270. 导 出
  271. </el-button>
  272. <el-button
  273. :size="size"
  274. :disabled="selectData.length !== 1"
  275. @click="openModifyBuyerDialog(selectData[0])"
  276. >
  277. 转 派
  278. </el-button>
  279. <el-button
  280. :size="size"
  281. :disabled="!selectData.length"
  282. @click="openDocumentsReturnDialog(selectData)"
  283. >
  284. 退回需求
  285. </el-button>
  286. <!-- <el-button
  287. :size="size"
  288. :disabled="selectData.length !== 1"
  289. @click="shutDown(selectData[0])"
  290. >
  291. 行关闭
  292. </el-button> -->
  293. <el-button
  294. :size="size"
  295. :disabled="!selectData.length"
  296. @click="openFristDirectDialog(selectData)"
  297. >
  298. 协议直采
  299. </el-button>
  300. </el-col>
  301. </el-row>
  302. <el-table
  303. :data="tableData"
  304. size="mini"
  305. style="width: 100%; margin: 20px 0 0 0"
  306. @row-dblclick="openSeeDialog"
  307. @selection-change="selectionChange"
  308. >
  309. <el-table-column fixed width="55" align="center" type="selection">
  310. </el-table-column>
  311. <el-table-column
  312. v-for="(column, index) in tableColumns"
  313. :key="index"
  314. :prop="column.key"
  315. :label="column.title"
  316. :width="column.width || 180"
  317. :show-overflow-tooltip="column.showOverflowTooltip || true"
  318. >
  319. <template slot-scope="scope">
  320. <dict-tag
  321. v-if="column.referName"
  322. :size="size"
  323. :value="scope.row[column.key]"
  324. :options="dict.type[column.referName]"
  325. />
  326. <span v-else>{{ scope.row[column.key] }}</span>
  327. </template>
  328. </el-table-column>
  329. </el-table>
  330. <pagination
  331. :total="page.total"
  332. :page.sync="page.pageNum"
  333. :limit.sync="page.pageSize"
  334. @pagination="queryList(params, page)"
  335. />
  336. </el-card>
  337. </template>