index.vue 7.6 KB

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