index.vue 11 KB

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