index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  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="24" :xs="24">
  10. <div class="main-right-box">
  11. <div class="main-search-box">
  12. <el-form
  13. :model="queryParams"
  14. ref="queryForm"
  15. size="small"
  16. :inline="true"
  17. v-show="showSearch"
  18. >
  19. <!-- <el-form-item label="编号" prop="id">
  20. <el-input v-model="queryParams.id" placeholder="请输入编号" clearable
  21. @keyup.enter.native="handleQuery"/>
  22. </el-form-item> -->
  23. <el-form-item label="机构名称">
  24. <org-tree
  25. v-model="queryParams.orgId"
  26. @defaultKey="getDefaultKey"
  27. @checkChange="checkChange"
  28. @click="clickTreeNode"
  29. wholeTree
  30. ref="orgTree"
  31. ></org-tree>
  32. </el-form-item>
  33. <el-form-item label="演练场景" prop="drillProjects">
  34. <el-input
  35. v-model="queryParams.drillProjects"
  36. placeholder="请输入关键字"
  37. clearable
  38. @keyup.enter.native="handleQuery"
  39. />
  40. </el-form-item>
  41. <el-form-item label="演练项目" prop="drillType">
  42. <el-select
  43. v-model="queryParams.drillType"
  44. placeholder="请选择演练项目"
  45. clearable
  46. >
  47. <el-option
  48. v-for="dict in dict.type.core_drill_type"
  49. :key="dict.value"
  50. :label="dict.label"
  51. :value="dict.value"
  52. />
  53. </el-select>
  54. </el-form-item>
  55. <!-- <el-form-item>
  56. </el-form-item> -->
  57. </el-form>
  58. <el-row :gutter="10">
  59. <el-col :span="1.5">
  60. <el-button
  61. type="primary"
  62. icon="el-icon-search"
  63. size="mini"
  64. @click="handleQuery"
  65. >搜索
  66. </el-button
  67. >
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-button
  71. type="primary"
  72. icon="el-icon-refresh"
  73. size="mini"
  74. @click="resetQuery"
  75. >重置
  76. </el-button
  77. >
  78. </el-col>
  79. <el-col :span="1.5">
  80. <el-button
  81. type="primary"
  82. icon="el-icon-plus"
  83. size="mini"
  84. @click="handleAdd"
  85. v-hasPermi="['core:drillDictionary:add']"
  86. >新增范本
  87. </el-button>
  88. </el-col>
  89. <!-- <el-col :span="1.5">
  90. <el-button
  91. type="warning"
  92. plain
  93. icon="el-icon-download"
  94. size="mini"
  95. @click="handleExport"
  96. v-hasPermi="['core:drillDictionary:export']"
  97. >导出
  98. </el-button>
  99. </el-col>-->
  100. <right-toolbar
  101. :showSearch.sync="showSearch"
  102. @queryTable="getList"
  103. ></right-toolbar>
  104. </el-row>
  105. </div>
  106. <el-table
  107. border
  108. height="646"
  109. v-loading="loading"
  110. :data="drillDictionaryList"
  111. @selection-change="handleSelectionChange"
  112. >
  113. <el-table-column
  114. label="序号"
  115. type="index"
  116. align="center"
  117. width="60"
  118. />
  119. <el-table-column
  120. label="机构名称"
  121. align="center"
  122. width="250"
  123. prop="orgName"
  124. />
  125. <el-table-column
  126. label="演练项目"
  127. align="center"
  128. width="180"
  129. prop="drillType"
  130. >
  131. <template slot-scope="scope">
  132. <dict-tag
  133. :options="dict.type.core_drill_type"
  134. :value="scope.row.drillType"
  135. />
  136. </template>
  137. </el-table-column>
  138. <!-- <el-table-column
  139. label="演练类型"
  140. align="left"
  141. align="center"
  142. width="180"
  143. prop="drillType"
  144. >
  145. <template slot-scope="scope">
  146. <dict-tag
  147. :options="dict.type.core_drill_category"
  148. :value="scope.row.drillCategory"
  149. />
  150. </template>
  151. </el-table-column>-->
  152. <el-table-column label="演练场景" scoped-slot="drillProjects" align="center" width="180"
  153. prop="drillProjects">
  154. <template slot-scope="scope">
  155. <div class="ellipsis" :title="scope.row.drillProjects">{{ scope.row.drillProjects }}</div>
  156. </template>
  157. </el-table-column>
  158. <el-table-column
  159. label="预设案由"
  160. scoped-slot="defaultCause"
  161. :show-overflow-tooltip="true"
  162. align="center"
  163. prop="defaultCause"
  164. >
  165. </el-table-column>
  166. <el-table-column
  167. label="操作"
  168. align="center"
  169. width="150"
  170. class-name="small-padding fixed-width"
  171. >
  172. <template slot-scope="scope">
  173. <el-button
  174. size="mini"
  175. type="text"
  176. icon="el-icon-edit-outline"
  177. v-if="canEdit(scope.row)"
  178. @click="handleUpdate(scope.row)"
  179. v-hasPermi="['core:drillDictionary:edit']"
  180. >编辑
  181. </el-button>
  182. <BtnTip
  183. size="mini"
  184. type="text"
  185. icon="el-icon-delete"
  186. v-if="canDelete(scope.row)"
  187. @click="handleDelete(scope.row)"
  188. v-hasPermi="['core:drillDictionary:remove']"
  189. >删除
  190. </BtnTip>
  191. </template>
  192. </el-table-column>
  193. </el-table>
  194. <pagination
  195. v-show="total > 0"
  196. :total="total"
  197. :page.sync="queryParams.pageNum"
  198. :limit.sync="queryParams.pageSize"
  199. @pagination="getList"
  200. />
  201. </div>
  202. </el-col>
  203. </el-row>
  204. <!-- 添加或修改预案演练库对话框 -->
  205. <DialogCom
  206. :title="title"
  207. :visible.sync="open"
  208. width="1000px"
  209. append-to-body
  210. >
  211. <el-form ref="form" :model="form" :rules="rules" label-width="90px">
  212. <el-form-item label="演练项目" prop="drillType" style="width: 100%">
  213. <el-select
  214. v-model="form.drillType"
  215. placeholder="请选择演练项目"
  216. style="width: 100%"
  217. >
  218. <el-option
  219. v-for="dict in dict.type.core_drill_type"
  220. :key="dict.value"
  221. :label="dict.label"
  222. :value="dict.value"
  223. ></el-option>
  224. </el-select>
  225. </el-form-item>
  226. <!-- <el-form-item label="演练类型" prop="drillCategory" style="width: 100%">
  227. <el-select
  228. v-model="form.drillCategory"
  229. placeholder="请选择演练类型"
  230. style="width: 100%"
  231. >
  232. <el-option
  233. v-for="dict in dict.type.core_drill_category"
  234. :key="dict.value"
  235. :label="dict.label"
  236. :value="dict.value"
  237. ></el-option>
  238. </el-select>
  239. </el-form-item>-->
  240. <el-form-item label="演练场景" prop="drillProjects">
  241. <el-input v-model="form.drillProjects" maxlength="50" placeholder="请输入演练场景"/>
  242. </el-form-item>
  243. <el-form-item label="预设案由" prop="defaultCause">
  244. <k-textarea
  245. v-model="form.defaultCause"
  246. :length="2000"
  247. :row="20"
  248. show-word-limit
  249. placeholder="请输入预设案由"
  250. />
  251. </el-form-item>
  252. </el-form>
  253. <div slot="footer" class="dialog-footer">
  254. <el-button type="primary" @click="submitForm">确 定</el-button>
  255. <el-button @click="cancel">取 消</el-button>
  256. </div>
  257. </DialogCom>
  258. </div>
  259. </template>
  260. <script>
  261. import {
  262. listDrillDictionary,
  263. getDrillDictionary,
  264. delDrillDictionary,
  265. addDrillDictionary,
  266. updateDrillDictionary,
  267. } from "@/api/core/drill/drillDictionary";
  268. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  269. import BtnTip from "@/components/btnTip";
  270. import tableList from "@/mixins/tableList";
  271. import {queryKnowledgeList} from "@/api/core/edu/knowledge";
  272. import KTextarea from "@/components/common/textarea.vue";
  273. import {mapGetters} from "vuex";
  274. export default {
  275. name: "DrillDictionary",
  276. components: {OrgTree, BtnTip, KTextarea},
  277. dicts: ["core_drill_type", "core_drill_category"],
  278. mixins: [tableList],
  279. data() {
  280. return {
  281. // 遮罩层
  282. loading: true,
  283. // 选中数组
  284. ids: [],
  285. // 非单个停用
  286. single: true,
  287. // 非多个停用
  288. multiple: true,
  289. // 显示搜索条件
  290. showSearch: true,
  291. // 总条数
  292. total: 0,
  293. // 预案演练库表格数据
  294. drillDictionaryList: [],
  295. // 弹出层标题
  296. title: "",
  297. // 是否显示弹出层
  298. open: false,
  299. // 查询参数
  300. queryParams: {
  301. pageNum: 1,
  302. pageSize: 10,
  303. drillType: null,
  304. drillTypeName: null,
  305. drillProjects: null,
  306. defaultCause: null,
  307. checkSub: true,
  308. },
  309. // 表单参数
  310. form: {},
  311. // 表单校验
  312. rules: {
  313. drillType: [{required: true, message: "请选择演练项目"}],
  314. drillCategory: [{required: true, message: "请选中演练类型"}],
  315. defaultCause: [{required: true, message: "请输入预设案由"}],
  316. drillProjects: [{required: true, message: "请输入演练场景"}],
  317. },
  318. };
  319. },
  320. computed: {
  321. ...mapGetters(["orgId"]),
  322. },
  323. created() {
  324. // this.getList();
  325. },
  326. methods: {
  327. /** 查询预案演练库列表 */
  328. getList() {
  329. this.loading = true;
  330. listDrillDictionary(this.queryParams).then((response) => {
  331. this.drillDictionaryList = response.rows;
  332. this.total = response.total;
  333. this.loading = false;
  334. });
  335. },
  336. // 取消按钮
  337. cancel() {
  338. this.open = false;
  339. this.reset();
  340. },
  341. // 表单重置
  342. reset() {
  343. this.form = {
  344. id: null,
  345. orgId: this.queryParams.orgId,
  346. drillType: null,
  347. drillProjects: null,
  348. defaultCause: null,
  349. checkSub: true,
  350. };
  351. this.resetForm("form");
  352. },
  353. getDefaultKey(key) {
  354. this.queryParams.orgId = key;
  355. this.getList();
  356. },
  357. //单选框状态改变
  358. checkChange(state) {
  359. this.queryParams.checkSub = state;
  360. this.handleQuery();
  361. },
  362. // 节点单击事件
  363. clickTreeNode(data) {
  364. this.queryParams.orgId = data.id;
  365. this.handleQuery();
  366. },
  367. initKnowledgeList() {
  368. queryKnowledgeList().then((response) => {
  369. this.knowledgeList = response;
  370. });
  371. },
  372. /** 搜索按钮操作 */
  373. handleQuery() {
  374. this.queryParams.pageNum = 1;
  375. this.getList();
  376. },
  377. /** 重置按钮操作 */
  378. resetQuery() {
  379. this.resetForm("queryForm");
  380. this.$refs["orgTree"].setSelectTop();
  381. this.queryParams.checkSub = true;
  382. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub)
  383. this.handleQuery();
  384. },
  385. // 多选框选中数据
  386. handleSelectionChange(selection) {
  387. this.ids = selection.map((item) => item.id);
  388. this.single = selection.length !== 1;
  389. this.multiple = !selection.length;
  390. },
  391. /** 新增按钮操作 */
  392. handleAdd() {
  393. this.reset();
  394. this.open = true;
  395. this.title = "新增演练范本";
  396. },
  397. canEdit(row) {
  398. return row.orgId == this.$store.getters.orgId;
  399. },
  400. /** 修改按钮操作 */
  401. handleUpdate(row) {
  402. this.reset();
  403. const id = row.id || this.ids;
  404. getDrillDictionary(id).then((response) => {
  405. this.form = response.data;
  406. this.open = true;
  407. this.title = "编辑演练范本";
  408. });
  409. },
  410. /** 提交按钮 */
  411. submitForm() {
  412. this.$refs["form"].validate((valid) => {
  413. if (valid) {
  414. if (this.form.id != null) {
  415. updateDrillDictionary(this.form).then((response) => {
  416. this.$modal.msgSuccess("修改成功");
  417. this.open = false;
  418. this.getList();
  419. });
  420. } else {
  421. addDrillDictionary(this.form).then((response) => {
  422. this.$modal.msgSuccess("新增成功");
  423. this.open = false;
  424. this.getList();
  425. });
  426. }
  427. }
  428. });
  429. },
  430. canDelete(row) {
  431. return row.orgId == this.$store.getters.orgId;
  432. },
  433. /** 删除按钮操作 */
  434. handleDelete(row) {
  435. const ids = row.id || this.ids;
  436. delDrillDictionary(ids)
  437. .then((response) => {
  438. this.getList();
  439. this.$modal.msgSuccess("删除成功");
  440. })
  441. .catch(() => {
  442. this.$modal.msgSuccess("删除失败");
  443. });
  444. // this.$modal.confirm('是否确认删除预案演练库编号为"' + ids + '"的数据项?').then(function () {
  445. // return delDrillDictionary(ids);
  446. // }).then(() => {
  447. // this.getList();
  448. // this.$modal.msgSuccess("删除成功");
  449. // }).catch(() => {
  450. // });
  451. },
  452. /** 导出按钮操作 */
  453. handleExport() {
  454. this.download(
  455. "core/drillDictionary/export",
  456. {
  457. ...this.queryParams,
  458. },
  459. `drillDictionary_${new Date().getTime()}.xlsx`
  460. );
  461. },
  462. },
  463. };
  464. </script>
  465. <style>
  466. .ellipsis {
  467. white-space: nowrap;
  468. overflow: hidden;
  469. text-overflow: ellipsis;
  470. }
  471. </style>