index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 搜索表单 -->
  5. <index-search :typeList="typeList" @search="reload"/>
  6. <!-- 数据表格 -->
  7. <ele-pro-table
  8. ref="table"
  9. height="calc(100vh - 325px)"
  10. :columns="columns"
  11. :datasource="datasource"
  12. :selection.sync="selection"
  13. row-key="id"
  14. >
  15. <!-- 表头工具栏 -->
  16. <template v-slot:toolbar>
  17. <el-button
  18. size="small"
  19. type="primary"
  20. icon="el-icon-plus"
  21. class="ele-btn-icon"
  22. @click="openEdit('','add')"
  23. >
  24. 新建
  25. </el-button>
  26. <el-button
  27. size="small"
  28. type="danger"
  29. icon="el-icon-delete"
  30. class="ele-btn-icon"
  31. @click="removeBatch"
  32. plain
  33. >
  34. 删除
  35. </el-button>
  36. <!-- <el-button-->
  37. <!-- size="small"-->
  38. <!-- type="primary"-->
  39. <!-- icon="el-icon-upload2"-->
  40. <!-- class="ele-btn-icon"-->
  41. <!-- plain-->
  42. <!-- >-->
  43. <!-- 导出-->
  44. <!-- </el-button>-->
  45. <!-- <el-button-->
  46. <!-- size="small"-->
  47. <!-- type="primary"-->
  48. <!-- icon="el-icon-download"-->
  49. <!-- class="ele-btn-icon"-->
  50. <!-- plain-->
  51. <!-- >-->
  52. <!-- 导入-->
  53. <!-- </el-button>-->
  54. </template>
  55. <!-- 操作列 -->
  56. <template v-slot:action="{ row }">
  57. <el-link
  58. v-if="row.status!=1"
  59. type="primary"
  60. :underline="false"
  61. icon="el-icon-edit"
  62. @click="openEdit(row,'edit')"
  63. >
  64. 修改
  65. </el-link>
  66. <el-link
  67. type="primary"
  68. :underline="false"
  69. icon="el-icon-setting"
  70. @click="openEdit(row, 'view')"
  71. >
  72. 详情
  73. </el-link>
  74. <el-popconfirm
  75. v-if="row.status!=1"
  76. class="ele-action"
  77. title="确定要删除当前资质吗?"
  78. @confirm="remove(row)"
  79. >
  80. <template v-slot:reference>
  81. <el-link type="danger" :underline="false" icon="el-icon-delete">
  82. 删除
  83. </el-link>
  84. </template>
  85. </el-popconfirm>
  86. </template>
  87. <template v-slot:status="scope">
  88. <el-switch
  89. @change="(val)=>handleStatus(scope,val)"
  90. :active-value="1"
  91. :inactive-value="0"
  92. v-model="scope.row.status"
  93. active-color="#13ce66"
  94. inactive-color="#ff4949">
  95. </el-switch>
  96. </template>
  97. </ele-pro-table>
  98. </el-card>
  99. <!-- 新增/编辑/详情弹窗 -->
  100. <add-or-edit-dialog
  101. :addOrEditDialogFlag.sync="addOrEditDialogFlag"
  102. v-if="addOrEditDialogFlag"
  103. ref="addOrEditDialogRef"
  104. :data="current"
  105. :typeList="typeList"
  106. @reload="reload"
  107. />
  108. </div>
  109. </template>
  110. <script>
  111. import addOrEditDialog from './components/addOrEditDialog.vue';
  112. import dictMixins from '@/mixins/dictMixins';
  113. import FileUpload from "@/components/upload/fileUpload.vue";
  114. import {getFile} from "@/api/system/file";
  115. import {reviewStatus} from "@/enum/dict";
  116. import {getSubTwoLevelAPI, getVersionManagePageAPI, updateStatus, versionManageDeleteAPI} from "@/api/versionManage";
  117. import indexSearch from "@/views/versionManage/components/index-search.vue";
  118. import {getSubPage} from "@/api/classifyManage";
  119. import {getByCode} from "@/api/system/dictionary-data";
  120. export default {
  121. name: 'technologyProduction',
  122. components: {
  123. FileUpload,
  124. indexSearch,
  125. addOrEditDialog
  126. },
  127. mixins: [dictMixins],
  128. data() {
  129. return {
  130. levelOptions: [
  131. {
  132. label: '初级',
  133. value: '1'
  134. },
  135. {
  136. label: '中级',
  137. value: '2'
  138. },
  139. {
  140. label: '高级',
  141. value: '3'
  142. }
  143. ],
  144. isView: false,
  145. // 表格列配置
  146. columns: [
  147. {
  148. columnKey: 'selection',
  149. type: 'selection',
  150. width: 45,
  151. align: 'center',
  152. fixed: 'left'
  153. },
  154. {
  155. label: '序号',
  156. type: 'index',
  157. width: 55,
  158. align: 'center'
  159. },
  160. {
  161. slot: 'name',
  162. prop: 'name',
  163. label: '名称',
  164. showOverflowTooltip: true,
  165. align: 'center',
  166. minWidth: 110
  167. },
  168. {
  169. slot: 'type',
  170. prop: 'type',
  171. label: '分类',
  172. showOverflowTooltip: true,
  173. align: 'center',
  174. formatter: (row, column) => {
  175. return this.getDictV('version_rule_type',row.type) ;
  176. },
  177. minWidth: 110
  178. },
  179. {
  180. slot: 'getExample',
  181. prop: 'getExample',
  182. label: '规则示例',
  183. showOverflowTooltip: true,
  184. align: 'center',
  185. formatter: (_row, _column, cellValue) => {
  186. let value = _row.note || (_row.noteType == 1 ? 'A' : '1')
  187. return value + _row.mark + _row.versionNumber
  188. },
  189. minWidth: 120
  190. },
  191. {
  192. label: '是否启用',
  193. prop: 'status',
  194. slot: 'status',
  195. align: "center",
  196. width: 120,
  197. },
  198. {
  199. columnKey: 'action',
  200. label: '操作',
  201. width: 260,
  202. align: 'center',
  203. resizable: false,
  204. slot: 'action',
  205. showOverflowTooltip: true
  206. }
  207. ],
  208. // 表格选中数据
  209. selection: [],
  210. dictList: {},
  211. // 当前编辑数据
  212. current: null,
  213. typeList: [],
  214. // 是否显示编辑弹窗
  215. addOrEditDialogFlag: false,
  216. };
  217. },
  218. created() {
  219. this.getTypeList()
  220. },
  221. computed: {},
  222. methods: {
  223. // getTypeName(list, val, callBack) {
  224. // let find = list.find(item => callBack(item, val)) || {}
  225. // if (find.name) {
  226. // return find.name
  227. // } else {
  228. // for (let i = 0; i < list.length; i++) {
  229. // let find = list[i].subList.find(item => callBack(item, val)) || {}
  230. // if (find.name) {
  231. // return find.name
  232. // }
  233. // }
  234. // }
  235. // },
  236. getDictV(code, val) {
  237. if (!this.dictList[code]) return '';
  238. return this.dictList[code].find(item => item.value == val)?.label
  239. },
  240. async getDictList(code) {
  241. let {data: res} = await getByCode(code)
  242. this.dictList[code] = res.map(item => {
  243. let values = Object.keys(item)
  244. return {
  245. value: values[0],
  246. label: item[values[0]]
  247. }
  248. })
  249. },
  250. /* 表格数据源 */
  251. async datasource({page, limit, where, order}) {
  252. await this.getDictList('version_rule_type')
  253. return await getVersionManagePageAPI({
  254. ...where,
  255. ...order,
  256. pageNum: page,
  257. size: limit
  258. });
  259. },
  260. handleStatus(scope, val) {
  261. let msg = val == 1 ? '是否启用该规则' : '是否关闭该规则'
  262. this.$confirm(msg, '提示', {
  263. type: 'warning'
  264. }).then(async () => {
  265. await updateStatus(
  266. {
  267. id: scope.row.id,
  268. status: val
  269. }
  270. )
  271. this.$message.success('操作成功')
  272. }).catch(() => {
  273. scope.row.status = val == 1 ? 0 : 1
  274. })
  275. },
  276. async getTypeList() {
  277. this.typeList = await getSubTwoLevelAPI({
  278. parentId: 0,
  279. pageNum: 1,
  280. size: 9999
  281. })
  282. console.log(this.typeList);
  283. },
  284. downloadFile(file) {
  285. getFile({objectName: file.storePath}, file.name);
  286. },
  287. /* 刷新表格 */
  288. reload(where) {
  289. this.$refs.table.reload({page: 1, where: where});
  290. },
  291. /* 打开编辑弹窗 */
  292. openEdit(row = {}, type) {
  293. this.addOrEditDialogFlag = true
  294. this.$nextTick(() => {
  295. this.$refs.addOrEditDialogRef.init(type, {...row})
  296. })
  297. },
  298. /* 删除 */
  299. remove(row) {
  300. const loading = this.$loading({lock: true});
  301. versionManageDeleteAPI([row.id])
  302. .then((msg) => {
  303. loading.close();
  304. this.$message.success('删除成功');
  305. this.reload();
  306. })
  307. .catch((e) => {
  308. loading.close();
  309. // this.$message.error(e.message);
  310. });
  311. },
  312. /* 批量删除 */
  313. removeBatch() {
  314. if (!this.selection.length) return this.$message.error('请至少选择一条数据');
  315. if (this.selection.some(item => item.status == 1)) return this.$message.error('启用状态的规则不允许删除!请检查');
  316. this.$confirm('确定要删除选中的规则吗?', '提示', {
  317. type: 'warning'
  318. }).then(() => {
  319. const loading = this.$loading({lock: true});
  320. versionManageDeleteAPI(this.selection.map((d) => d.id))
  321. .then((msg) => {
  322. loading.close();
  323. this.$message.success('删除成功');
  324. this.reload();
  325. })
  326. .catch((e) => {
  327. loading.close();
  328. // this.$message.error(e.message);
  329. });
  330. })
  331. .catch(() => {
  332. });
  333. }
  334. }
  335. };
  336. </script>