index.vue 9.0 KB

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