index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--机构数据-->
  5. <el-col :span="4" :xs="24">
  6. <org-tree v-model="queryParams.orgId" @defaultKey="getDefaultKey" @checkChange="checkChange"
  7. @click="clickTreeNode" hangsheTree></org-tree>
  8. </el-col>
  9. <el-col :span="20" :xs="24">
  10. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  11. <el-form-item label="编号" prop="id">
  12. <el-input v-model="queryParams.id" placeholder="请输入编号" clearable
  13. @keyup.enter.native="handleQuery"/>
  14. </el-form-item>
  15. <el-form-item label="演练类型" prop="drillType">
  16. <el-select v-model="queryParams.drillType" placeholder="请选择演练类型" clearable>
  17. <el-option
  18. v-for="dict in dict.type.core_drill_type"
  19. :key="dict.value"
  20. :label="dict.label"
  21. :value="dict.value"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  27. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <el-row :gutter="10" class="mb8">
  31. <el-col :span="1.5">
  32. <el-button
  33. type="primary"
  34. plain
  35. icon="el-icon-plus"
  36. size="mini"
  37. @click="handleAdd"
  38. v-hasPermi="['core:drillDictionary:add']"
  39. >新增
  40. </el-button>
  41. </el-col>
  42. <el-col :span="1.5">
  43. <el-button
  44. type="success"
  45. plain
  46. icon="el-icon-edit"
  47. size="mini"
  48. :disabled="single"
  49. @click="handleUpdate"
  50. v-hasPermi="['core:drillDictionary:edit']"
  51. >修改
  52. </el-button>
  53. </el-col>
  54. <el-col :span="1.5">
  55. <el-button
  56. type="danger"
  57. plain
  58. icon="el-icon-delete"
  59. size="mini"
  60. :disabled="multiple"
  61. @click="handleDelete"
  62. v-hasPermi="['core:drillDictionary:remove']"
  63. >删除
  64. </el-button>
  65. </el-col>
  66. <el-col :span="1.5">
  67. <el-button
  68. type="warning"
  69. plain
  70. icon="el-icon-download"
  71. size="mini"
  72. @click="handleExport"
  73. v-hasPermi="['core:drillDictionary:export']"
  74. >导出
  75. </el-button>
  76. </el-col>
  77. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  78. </el-row>
  79. <el-table v-loading="loading" :data="drillDictionaryList" @selection-change="handleSelectionChange">
  80. <el-table-column type="selection" width="55" align="center"/>
  81. <el-table-column label="演练类型" align="center" prop="drillType">
  82. <template slot-scope="scope">
  83. <dict-tag :options="dict.type.core_drill_type" :value="scope.row.drillType"/>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="演练项目" align="center" prop="drillProjects"/>
  87. <el-table-column label="预设案由" align="center" prop="defaultCause"/>
  88. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  89. <template slot-scope="scope">
  90. <el-button
  91. size="mini"
  92. type="text"
  93. icon="el-icon-edit"
  94. @click="handleUpdate(scope.row)"
  95. v-hasPermi="['core:drillDictionary:edit']"
  96. >修改
  97. </el-button>
  98. <el-button
  99. size="mini"
  100. type="text"
  101. icon="el-icon-delete"
  102. @click="handleDelete(scope.row)"
  103. v-hasPermi="['core:drillDictionary:remove']"
  104. >删除
  105. </el-button>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <pagination
  110. v-show="total>0"
  111. :total="total"
  112. :page.sync="queryParams.pageNum"
  113. :limit.sync="queryParams.pageSize"
  114. @pagination="getList"
  115. />
  116. </el-col>
  117. </el-row>
  118. <!-- 添加或修改预案演练库对话框 -->
  119. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  120. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  121. <el-form-item label="演练类型" prop="drillType">
  122. <el-select v-model="form.drillType" placeholder="请选择演练类型">
  123. <el-option
  124. v-for="dict in dict.type.core_drill_type"
  125. :key="dict.value"
  126. :label="dict.label"
  127. :value="dict.value"
  128. ></el-option>
  129. </el-select>
  130. </el-form-item>
  131. <el-form-item label="演练类型名称" prop="drillTypeName">
  132. <el-input v-model="form.drillTypeName" placeholder="请输入演练类型名称"/>
  133. </el-form-item>
  134. <el-form-item label="演练项目" prop="drillProjects">
  135. <el-input v-model="form.drillProjects" type="textarea" placeholder="请输入内容"/>
  136. </el-form-item>
  137. <el-form-item label="预设案由" prop="defaultCause">
  138. <el-input v-model="form.defaultCause" type="textarea" placeholder="请输入内容"/>
  139. </el-form-item>
  140. </el-form>
  141. <div slot="footer" class="dialog-footer">
  142. <el-button type="primary" @click="submitForm">确 定</el-button>
  143. <el-button @click="cancel">取 消</el-button>
  144. </div>
  145. </el-dialog>
  146. </div>
  147. </template>
  148. <script>
  149. import {
  150. listDrillDictionary,
  151. getDrillDictionary,
  152. delDrillDictionary,
  153. addDrillDictionary,
  154. updateDrillDictionary
  155. } from "@/api/drill/drillDictionary";
  156. import OrgTree from "@/components/orgTree/index.vue";
  157. import kOrgTree from "@/components/k-orgTree/index.vue";
  158. import KFileUpload from "@/components/K-FileUpload/index.vue";
  159. import tableList from "@/mixins/tableList";
  160. export default {
  161. name: "DrillDictionary",
  162. components: {OrgTree},
  163. dicts: ['core_drill_type'],
  164. mixins: [tableList],
  165. data() {
  166. return {
  167. // 遮罩层
  168. loading: true,
  169. // 选中数组
  170. ids: [],
  171. // 非单个禁用
  172. single: true,
  173. // 非多个禁用
  174. multiple: true,
  175. // 显示搜索条件
  176. showSearch: true,
  177. // 总条数
  178. total: 0,
  179. // 预案演练库表格数据
  180. drillDictionaryList: [],
  181. // 弹出层标题
  182. title: "",
  183. // 是否显示弹出层
  184. open: false,
  185. // 查询参数
  186. queryParams: {
  187. pageNum: 1,
  188. pageSize: 10,
  189. drillType: null,
  190. drillTypeName: null,
  191. drillProjects: null,
  192. defaultCause: null,
  193. orgId: null,
  194. orgName: null,
  195. },
  196. // 表单参数
  197. form: {},
  198. // 表单校验
  199. rules: {}
  200. };
  201. },
  202. created() {
  203. this.getList();
  204. },
  205. methods: {
  206. /** 查询预案演练库列表 */
  207. getList() {
  208. this.loading = true;
  209. listDrillDictionary(this.queryParams).then(response => {
  210. this.drillDictionaryList = response.rows;
  211. this.total = response.total;
  212. this.loading = false;
  213. });
  214. },
  215. // 取消按钮
  216. cancel() {
  217. this.open = false;
  218. this.reset();
  219. },
  220. // 表单重置
  221. reset() {
  222. this.form = {
  223. id: null,
  224. drillType: null,
  225. drillTypeName: null,
  226. drillProjects: null,
  227. defaultCause: null,
  228. orgId: null,
  229. orgName: null,
  230. orgPath: null,
  231. deleted: null
  232. };
  233. this.resetForm("form");
  234. },
  235. getDefaultKey(key) {
  236. this.queryParams.orgId = key;
  237. this.getList();
  238. },
  239. //单选框状态改变
  240. checkChange(state) {
  241. this.queryParams.checkSub = state;
  242. this.handleQuery();
  243. },
  244. // 节点单击事件
  245. clickTreeNode(data) {
  246. this.initPlanRoleList();
  247. this.queryParams.orgId = data.id;
  248. this.handleQuery();
  249. },
  250. /** 搜索按钮操作 */
  251. handleQuery() {
  252. this.queryParams.pageNum = 1;
  253. this.getList();
  254. },
  255. /** 重置按钮操作 */
  256. resetQuery() {
  257. this.resetForm("queryForm");
  258. this.handleQuery();
  259. },
  260. // 多选框选中数据
  261. handleSelectionChange(selection) {
  262. this.ids = selection.map(item => item.id)
  263. this.single = selection.length !== 1
  264. this.multiple = !selection.length
  265. },
  266. /** 新增按钮操作 */
  267. handleAdd() {
  268. this.reset();
  269. this.open = true;
  270. this.title = "添加预案演练库";
  271. },
  272. /** 修改按钮操作 */
  273. handleUpdate(row) {
  274. this.reset();
  275. const id = row.id || this.ids
  276. getDrillDictionary(id).then(response => {
  277. this.form = response.data;
  278. this.open = true;
  279. this.title = "修改预案演练库";
  280. });
  281. },
  282. /** 提交按钮 */
  283. submitForm() {
  284. this.$refs["form"].validate(valid => {
  285. if (valid) {
  286. if (this.form.id != null) {
  287. updateDrillDictionary(this.form).then(response => {
  288. this.$modal.msgSuccess("修改成功");
  289. this.open = false;
  290. this.getList();
  291. });
  292. } else {
  293. addDrillDictionary(this.form).then(response => {
  294. this.$modal.msgSuccess("新增成功");
  295. this.open = false;
  296. this.getList();
  297. });
  298. }
  299. }
  300. });
  301. },
  302. /** 删除按钮操作 */
  303. handleDelete(row) {
  304. const ids = row.id || this.ids;
  305. this.$modal.confirm('是否确认删除预案演练库编号为"' + ids + '"的数据项?').then(function () {
  306. return delDrillDictionary(ids);
  307. }).then(() => {
  308. this.getList();
  309. this.$modal.msgSuccess("删除成功");
  310. }).catch(() => {
  311. });
  312. },
  313. /** 导出按钮操作 */
  314. handleExport() {
  315. this.download('core/drillDictionary/export', {
  316. ...this.queryParams
  317. }, `drillDictionary_${new Date().getTime()}.xlsx`)
  318. }
  319. }
  320. };
  321. </script>