classify.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="app-container">
  3. <el-card class="box-card">
  4. <save-form
  5. ref="listQuery"
  6. :model="listQuery"
  7. @submit="handleQuery"
  8. :inline="true"
  9. >
  10. <el-form-item label="分类名称">
  11. <el-input
  12. v-model="listQuery.name"
  13. placeholder="请输入分类名称"
  14. clearable
  15. size="small"
  16. style="width: 240px"
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button
  22. type="primary"
  23. icon="el-icon-search"
  24. size="small"
  25. native-type="submit"
  26. >搜索</el-button
  27. >
  28. </el-form-item>
  29. </save-form>
  30. <el-row :gutter="10" class="mb8">
  31. <el-col :span="1.5">
  32. <el-button
  33. v-permisaction="['process:admin:classify:add']"
  34. type="primary"
  35. icon="el-icon-plus"
  36. size="mini"
  37. @click="handleCreate"
  38. >新增</el-button
  39. >
  40. </el-col>
  41. <!-- <el-col :span="1.5">
  42. <el-button
  43. v-permisaction="['system:sysrole:edit']"
  44. type="success"
  45. icon="el-icon-edit"
  46. size="mini"
  47. :disabled="single"
  48. @click="handleUpdate"
  49. >编辑</el-button>
  50. </el-col>
  51. <el-col :span="1.5">
  52. <el-button
  53. v-permisaction="['system:sysrole:remove']"
  54. type="danger"
  55. icon="el-icon-delete"
  56. size="mini"
  57. :disabled="multiple"
  58. @click="handleDelete"
  59. >删除</el-button>
  60. </el-col> -->
  61. </el-row>
  62. <el-table
  63. v-loading="loading"
  64. border
  65. :data="classifyList"
  66. @selection-change="handleSelectionChange"
  67. >
  68. <el-table-column type="selection" width="55" align="center" />
  69. <el-table-column label="ID" prop="id" width="120" />
  70. <el-table-column
  71. label="名称"
  72. prop="name"
  73. :show-overflow-tooltip="true"
  74. />
  75. <el-table-column
  76. label="创建者"
  77. prop="create_name"
  78. :show-overflow-tooltip="true"
  79. width="150"
  80. />
  81. <el-table-column
  82. label="创建时间"
  83. align="center"
  84. prop="create_time"
  85. width="180"
  86. >
  87. <template slot-scope="scope">
  88. <span>{{ parseTime(scope.row.create_time) }}</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column
  92. label="操作"
  93. align="center"
  94. class-name="small-padding fixed-width"
  95. >
  96. <template slot-scope="scope">
  97. <el-button
  98. v-permisaction="['process:admin:classify:edit']"
  99. size="mini"
  100. type="text"
  101. icon="el-icon-edit"
  102. @click="handleEdit(scope.row)"
  103. >编辑</el-button
  104. >
  105. <el-button
  106. v-permisaction="['process:admin:classify:delete']"
  107. size="mini"
  108. type="text"
  109. icon="el-icon-delete"
  110. @click="handleDelete(scope.row)"
  111. >删除</el-button
  112. >
  113. </template>
  114. </el-table-column>
  115. </el-table>
  116. <pagination
  117. v-show="total > 0"
  118. :total="total"
  119. :page.sync="queryParams.pageIndex"
  120. :limit.sync="queryParams.pageSize"
  121. @pagination="getList"
  122. />
  123. <el-dialog
  124. :title="dialogFormVisibleName === 1 ? '新建分类' : '编辑分类'"
  125. :visible.sync="open"
  126. width="600px"
  127. >
  128. <div class="tpl-create-content">
  129. <el-form
  130. ref="ruleForm"
  131. :model="ruleForm"
  132. :rules="rules"
  133. label-width="100px"
  134. >
  135. <el-form-item label="分类名称" prop="name" style="width: 95%">
  136. <el-input v-model="ruleForm.name" />
  137. </el-form-item>
  138. </el-form>
  139. <div slot="footer" class="dialog-footer" style="text-align: right">
  140. <el-button
  141. type="primary"
  142. @click="
  143. dialogFormVisibleName === 1
  144. ? submitForm('ruleForm')
  145. : editForm('ruleForm')
  146. "
  147. >提交</el-button
  148. >
  149. <el-button @click="open = false">取 消</el-button>
  150. </div>
  151. </div>
  152. </el-dialog>
  153. </el-card>
  154. </div>
  155. </template>
  156. <script>
  157. import {
  158. createClassify,
  159. classifyList,
  160. updateClassify,
  161. deleteClassify
  162. } from "@/api/process/admin/classify";
  163. import SaveForm from "@/components/save-form";
  164. export default {
  165. name: "Classify",
  166. components: {
  167. SaveForm
  168. },
  169. data() {
  170. return {
  171. dialogFormVisibleName: 1,
  172. queryParams: {},
  173. // 遮罩层
  174. loading: true,
  175. // 选中数组
  176. ids: [],
  177. // 非单个禁用
  178. single: true,
  179. // 非多个禁用
  180. multiple: true,
  181. // 总条数
  182. total: 0,
  183. // 是否显示弹出层
  184. open: false,
  185. // 查询参数
  186. classifyList: [],
  187. listQuery: {
  188. page: 1,
  189. per_page: 10
  190. },
  191. ruleForm: {
  192. id: undefined,
  193. name: ""
  194. },
  195. rules: {
  196. name: [{ required: true, message: "请输入流程分类", trigger: "blur" }]
  197. }
  198. };
  199. },
  200. mounted() {
  201. this.getList();
  202. },
  203. methods: {
  204. /** 查询角色列表 */
  205. getList() {
  206. this.loading = true;
  207. this.listQuery.page = this.queryParams.pageIndex;
  208. this.listQuery.per_page = this.queryParams.pageSize;
  209. classifyList(this.listQuery).then(response => {
  210. this.classifyList = response.data.data;
  211. this.queryParams.pageIndex = response.data.page;
  212. this.queryParams.pageSize = response.data.per_page;
  213. this.total = response.data.total_count;
  214. this.loading = false;
  215. });
  216. },
  217. handleCreate() {
  218. this.ruleForm = {
  219. id: undefined,
  220. name: ""
  221. };
  222. this.dialogFormVisibleName = 1;
  223. this.open = true;
  224. },
  225. handleEdit(row) {
  226. this.dialogFormVisibleName = 2;
  227. this.ruleForm.id = row.id;
  228. this.ruleForm.name = row.name;
  229. this.open = true;
  230. },
  231. submitForm(formName) {
  232. this.$refs[formName].validate(valid => {
  233. if (valid) {
  234. createClassify(this.ruleForm).then(response => {
  235. if (response !== undefined) {
  236. this.getList();
  237. this.$message({
  238. type: "success",
  239. message: "分类已增加!"
  240. });
  241. this.open = false;
  242. }
  243. });
  244. }
  245. });
  246. },
  247. editForm(formName) {
  248. this.$refs[formName].validate(valid => {
  249. if (valid) {
  250. updateClassify(this.ruleForm).then(response => {
  251. if (response !== undefined) {
  252. this.getList();
  253. this.$message({
  254. type: "success",
  255. message: "分类已更新!"
  256. });
  257. this.open = false;
  258. }
  259. });
  260. }
  261. });
  262. },
  263. handleQuery() {
  264. this.queryParams.pageIndex = 1;
  265. this.queryParams.pageSize = 10;
  266. this.getList();
  267. },
  268. handleDelete(row) {
  269. this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
  270. confirmButtonText: "确定",
  271. cancelButtonText: "取消",
  272. type: "warning"
  273. })
  274. .then(() => {
  275. deleteClassify({
  276. classifyId: row.id
  277. }).then(response => {
  278. if (response !== undefined) {
  279. this.getList();
  280. this.$message({
  281. type: "success",
  282. message: "分类已删除!"
  283. });
  284. }
  285. });
  286. })
  287. .catch(() => {
  288. this.$message({
  289. type: "info",
  290. message: "已取消删除"
  291. });
  292. });
  293. },
  294. handleSelectionChange() {}
  295. }
  296. };
  297. </script>