index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <script>
  2. import { FormColumns, SearchColumns } from "./column";
  3. import { LIST } from "@/api/business/purchase/contract";
  4. import { initPage, initDicts, initParams } from "@/utils/init";
  5. export default {
  6. name: "PuchaseContract",
  7. dicts: [...initDicts(SearchColumns), ...initDicts(FormColumns)],
  8. components: {
  9. AddModel: () => import("./add/index.vue"),
  10. SeeModel: () => import("./see/index.vue"),
  11. EditModel: () => import("./edit/index.vue"),
  12. ExportModel: () => import("./export/index.vue"),
  13. ImportModel: () => import("./import/index.vue"),
  14. RecordModel: () => import("./record/index.vue"),
  15. DeleteModel: () => import("./delete/index.vue"),
  16. TerminationModel: () => import("./termination/index.vue"),
  17. },
  18. data() {
  19. return {
  20. size: "mini",
  21. loading: false,
  22. searchColumns: SearchColumns,
  23. params: initParams(SearchColumns),
  24. tableData: [],
  25. currentData: [],
  26. tableColumns: FormColumns,
  27. page: { pageNum: 1, pageSize: 10, total: 0 },
  28. };
  29. },
  30. computed: {},
  31. created() {
  32. this.useQuery(this.params, this.page);
  33. },
  34. methods: {
  35. //
  36. async fetchList(prop, page) {
  37. try {
  38. // try
  39. this.loading = true;
  40. const { pageNum, pageSize } = page;
  41. const { code, rows, total } = await LIST({
  42. pageNum,
  43. pageSize,
  44. ...prop,
  45. });
  46. if (code === 200) {
  47. this.tableData = rows;
  48. this.page.total = total;
  49. }
  50. } catch (err) {
  51. // catch
  52. console.error(err);
  53. } finally {
  54. // finally
  55. this.loading = false;
  56. }
  57. },
  58. // 查 询
  59. useQuery(prop, page) {
  60. this.fetchList(prop, page);
  61. },
  62. // 重 置
  63. useReset() {
  64. this.page = initPage();
  65. this.params = initParams(SearchColumns);
  66. this.useQuery(this.params, this.page);
  67. },
  68. // 选 择
  69. useSelect(prop) {
  70. this.currentData = [prop];
  71. },
  72. // 新 增
  73. async useAdd() {
  74. const { open } = this.$refs.AddModel;
  75. await open();
  76. },
  77. // 删 除
  78. async useDelete(prop) {
  79. const [{ id }] = prop;
  80. const { open } = this.$refs.DeleteModel;
  81. await open(id);
  82. },
  83. // 编 辑
  84. async useEdit(prop) {
  85. const [{ id }] = prop;
  86. const { open } = this.$refs.EditModel;
  87. await open(id);
  88. },
  89. // 明 细
  90. async useSee(prop) {
  91. const [{ id }] = prop;
  92. const { open } = this.$refs.SeeModel;
  93. await open(id);
  94. },
  95. // 终 止
  96. async useTermination(prop) {
  97. const [{ id }] = prop;
  98. const { open } = this.$refs.TerminationModel;
  99. await open(id);
  100. },
  101. // 导 出
  102. async useExport(prop) {
  103. const { pageNum, pageSize } = this.page;
  104. const { open } = this.$refs.ExportModel;
  105. await open({ ...prop, pageNum, pageSize });
  106. },
  107. // 导 入
  108. async useImport() {
  109. const { open } = this.$refs.ImportModel;
  110. await open();
  111. },
  112. // 期初补录
  113. async useRecord() {
  114. const { open } = this.$refs.RecordModel;
  115. await open();
  116. },
  117. },
  118. };
  119. </script>
  120. <template>
  121. <el-card
  122. v-loading="loading"
  123. style="
  124. width: calc(100% - 20px);
  125. height: 100%;
  126. margin: 10px;
  127. padding: 0 20px 20px 0;
  128. "
  129. :body-style="{ padding: 0 }"
  130. >
  131. <see-model ref="SeeModel"></see-model>
  132. <add-model ref="AddModel" @success="useReset"></add-model>
  133. <record-model ref="RecordModel" @success="useReset"></record-model>
  134. <edit-model ref="EditModel" @success="useQuery(params, page)"></edit-model>
  135. <export-model ref="ExportModel"></export-model>
  136. <import-model ref="ImportModel"></import-model>
  137. <delete-model
  138. ref="DeleteModel"
  139. @success="useQuery(params, page)"
  140. ></delete-model>
  141. <termination-model
  142. ref="TerminationModel"
  143. @success="useQuery(params, page)"
  144. ></termination-model>
  145. <el-form
  146. :size="size"
  147. :model="params"
  148. label-width="auto"
  149. label-position="right"
  150. style="padding: 20px 20px 0"
  151. @submit.native.prevent
  152. >
  153. <el-row :gutter="20" style="display: flex; flex-wrap: wrap">
  154. <el-col
  155. v-for="column in searchColumns"
  156. :key="column.title"
  157. :span="column.span || 6"
  158. >
  159. <el-form-item :prop="column.key" :label="column.title">
  160. <el-input
  161. v-model="params[column.key]"
  162. :placeholder="column.placeholder"
  163. @keyup.enter.native="useQuery(params, page)"
  164. ></el-input>
  165. </el-form-item>
  166. </el-col>
  167. </el-row>
  168. </el-form>
  169. <el-row style="padding: 0 20px">
  170. <el-button :size="size" @click="useQuery(params, page)">
  171. 查 询
  172. </el-button>
  173. <el-button :size="size" @click="useReset"> 重 置 </el-button>
  174. <el-button :size="size" @click="useAdd"> 新 增 </el-button>
  175. <el-button :size="size" @click="useRecord"> 期初补录 </el-button>
  176. <el-button
  177. :size="size"
  178. :disabled="!currentData.length"
  179. @click="useEdit(currentData)"
  180. >
  181. 编 辑
  182. </el-button>
  183. <el-button
  184. :size="size"
  185. :disabled="!currentData.length"
  186. @click="useDelete(currentData)"
  187. >
  188. 删 除
  189. </el-button>
  190. <el-button
  191. :size="size"
  192. :disabled="!currentData.length"
  193. @click="useTermination(currentData)"
  194. >
  195. 终 止
  196. </el-button>
  197. <el-button :size="size" :disabled="!currentData.length">
  198. 变 更
  199. </el-button>
  200. <el-button :size="size" :disabled="!currentData.length">
  201. 归 档
  202. </el-button>
  203. <el-button
  204. :size="size"
  205. :disabled="!currentData.length"
  206. @click="useExport(params)"
  207. >
  208. 导 出
  209. </el-button>
  210. <!-- <el-button :size="size" @click="useImport"> 导 入 </el-button> -->
  211. </el-row>
  212. <el-table
  213. :size="size"
  214. :data="tableData"
  215. highlight-current-row
  216. @row-click="useSelect"
  217. @row-dblclick="useSee"
  218. style="width: 100%; margin: 20px 0 0 0"
  219. >
  220. <el-table-column
  221. v-for="(column, index) in tableColumns"
  222. :key="index"
  223. :prop="column.key"
  224. :label="column.title"
  225. :width="column.width || 180"
  226. show-overflow-tooltip
  227. >
  228. <template slot-scope="scope">
  229. <dict-tag
  230. v-if="column.inputType === 'Select'"
  231. :size="size"
  232. :value="scope.row[column.key]"
  233. :options="dict.type[column.referName]"
  234. />
  235. <dr-file-preview
  236. v-else-if="column.inputType === 'Upload'"
  237. v-model="scope.row[column.key]"
  238. ></dr-file-preview>
  239. <span v-else>{{ scope.row[column.key] }}</span>
  240. </template>
  241. </el-table-column>
  242. <!-- <el-table-column fixed="right" label="操作" width="150">
  243. <template slot-scope="scope">
  244. <el-button
  245. type="text"
  246. size="small"
  247. @click.native.prevent="useEdit(scope.row)"
  248. >
  249. 编 辑
  250. </el-button>
  251. <el-button
  252. type="text"
  253. size="small"
  254. @click.native.prevent="useEdit(scope.row)"
  255. >
  256. 变 更
  257. </el-button>
  258. <el-button
  259. type="text"
  260. size="small"
  261. @click.native.prevent="useEdit(scope.row)"
  262. >
  263. 归 档
  264. </el-button>
  265. <el-button
  266. type="text"
  267. size="small"
  268. @click.native.prevent="useTermination(scope.row)"
  269. >
  270. 终 止
  271. </el-button>
  272. <el-button
  273. type="text"
  274. size="small"
  275. @click.native.prevent="useDelete(scope.row)"
  276. >
  277. 删 除
  278. </el-button>
  279. </template>
  280. </el-table-column> -->
  281. </el-table>
  282. <pagination
  283. :total="page.total"
  284. :page.sync="page.pageNum"
  285. :limit.sync="page.pageSize"
  286. @pagination="useQuery(params, page)"
  287. />
  288. </el-card>
  289. </template>