index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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" @defaultOrg="getDefaultOrg" @checkChange="checkChange"
  7. @click="clickTreeNode"></org-tree>
  8. </el-col>
  9. <!--搜索栏-->
  10. <el-col :span="20" :xs="24">
  11. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
  12. label-width="68px">
  13. <el-form-item label="计划名称" prop="planName">
  14. <el-input v-model="queryParams.planName" placeholder="请输入计划名称" maxlength="50" clearable
  15. @keyup.enter.native="handleQuery"/>
  16. </el-form-item>
  17. <el-form-item label="机构类型" prop="orgType">
  18. <el-select style="width: 100%;" v-model="queryParams.orgType" placeholder="请选择" @change="changeSelect">
  19. <el-option v-for="dict in dict.type.sys_org_type" :key="dict.value" :label="dict.label"
  20. :value="`${dict.value}`"></el-option>
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="调阅角色" prop="roleId">
  24. <el-select v-model="queryParams.roleId" placeholder="请选择">
  25. <el-option v-for="item in roleList" :key="item.id" :label="item.roleName" :value="item.id"></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="调阅周期" prop="planCycle">
  29. <el-select style="width: 100%;" v-model="queryParams.planCycle" placeholder="请选择">
  30. <el-option v-for="dict in dict.type.sys_access_cycle" :key="dict.value" :label="dict.label"
  31. :value="`${dict.value}`"></el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="计划状态" prop="planStatus">
  35. <el-select style="width: 100%;" v-model="queryParams.planStatus" placeholder="请选择">
  36. <el-option v-for="dict in dict.type.plan_status" :key="dict.value" :label="dict.label"
  37. :value="`${dict.value}`"></el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"
  42. v-hasPermi="['core:accessPlan:list']">搜索
  43. </el-button>
  44. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  45. </el-form-item>
  46. </el-form>
  47. <el-row :gutter="10" class="mb8">
  48. <el-col :span="1.5">
  49. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  50. v-hasPermi="['core:accessPlan:add']" v-if="check==true" >新增
  51. </el-button>
  52. </el-col>
  53. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  54. </el-row>
  55. <el-table border
  56. height="600"
  57. size="small"
  58. v-loading="loading" :data="planList" row-key="id" :tree-props="{ children: 'children' }">
  59. <el-table-column prop="index" label="序号" width="80"></el-table-column>
  60. <el-table-column width="140" label="计划名称" align="center" prop="planName"/>
  61. <el-table-column width="140" label="创建机构" align="center" prop="orgName"/>
  62. <el-table-column label="机构类型" align="center" key="orgType" prop="orgType">
  63. <template slot-scope="scope">
  64. <dict-tag :options="dict.type.sys_org_type" :value="scope.row.orgType"/>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="调阅角色" align="center" prop="roleName"/>
  68. <el-table-column label="调阅周期" align="center" key="planCycle" prop="planCycle" width="80">
  69. <template slot-scope="scope">
  70. <dict-tag :options="dict.type.sys_access_cycle" :value="scope.row.planCycle"/>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="调阅频次" align="center" prop="planFrequency"/>
  74. <el-table-column label="计划状态" align="center" key="planStatus" prop="planStatus" width="80">
  75. <template slot-scope="scope">
  76. <dict-tag :options="dict.type.plan_status" :value="scope.row.planStatus"/>
  77. </template>
  78. </el-table-column>
  79. <!-- <el-table-column label="修改人" align="center" prop="updateBy"/>
  80. <el-table-column label="修改时间" align="center" prop="updateTime"/> -->
  81. <el-table-column label="备注" align="center" prop="description"/>
  82. <el-table-column label="操作" fixed="right" width="120" align="center" class-name="small-padding fixed-width">
  83. <template slot-scope="scope">
  84. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-if="scope.row.parentId==null && check==true"
  85. v-hasPermi="['core:accessPlan:edit','core:accessPlan:query']">编辑
  86. </el-button>
  87. <el-button size="mini" type="text" v-if="scope.row.isDistribute == 0 && scope.row.planStatus==0" icon="el-icon-arrow-down"
  88. @click="handDistribute(scope.row)" v-hasPermi="['core:accessPlan:add']">下发
  89. </el-button>
  90. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-if="scope.row.parentId==null && check==true"
  91. v-hasPermi="['core:accessPlan:remove']">删除
  92. </el-button>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. <!-- <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
  97. :limit.sync="queryParams.pageSize"
  98. @pagination="getList"/> -->
  99. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
  100. :limit.sync="queryParams.pageSize"
  101. @pagination="getList"/>
  102. </el-col>
  103. </el-row>
  104. <!-- 添加或修改监控调阅计划对话框 -->
  105. <DialogCom :title="title" :visible.sync="open" width="500px" append-to-body>
  106. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  107. <el-form-item label="计划名称" prop="planName">
  108. <el-input v-model="form.planName" placeholder="请输入计划名称" maxlength="50"/>
  109. </el-form-item>
  110. <el-form-item label="机构类型" prop="orgType">
  111. <el-select style="width: 100%;" v-model="form.orgType" placeholder="请选择" @change="changeSelect">
  112. <el-option v-for="dict in dict.type.sys_org_type" :key="dict.value" :label="dict.label"
  113. :value="`${dict.value}`"></el-option>
  114. </el-select>
  115. </el-form-item>
  116. <el-form-item label="调阅周期" prop="planCycle">
  117. <el-select style="width: 100%;" v-model="form.planCycle" placeholder="请选择">
  118. <el-option v-for="dict in dict.type.sys_access_cycle" :key="dict.value" :label="dict.label"
  119. :value="`${dict.value}`"></el-option>
  120. </el-select>
  121. </el-form-item>
  122. <el-form-item prop="startTime" v-if="form.planCycle == 0" label="开始日期">
  123. <el-date-picker style="width: 100%;" v-model="form.startTime" @change="startDateChanged" :picker-options="startDatepickerOptions"
  124. align="right" type="date" placeholder="选择开始日期">
  125. </el-date-picker>
  126. </el-form-item>
  127. <el-form-item prop="endTime" v-if="form.planCycle == 0" label="结束日期">
  128. <el-date-picker style="width: 100%;" v-model="form.endTime" :picker-options="endDatepickerOptions" align="right" type="date"
  129. placeholder="选择结束日期">
  130. </el-date-picker>
  131. </el-form-item>
  132. <el-form-item label="调阅角色" prop="roleId">
  133. <el-select style="width: 100%;" v-model="form.roleId" placeholder="请选择" @change="changeSelectOrgType">
  134. <el-option v-for="item in roleList" :key="item.id" :label="item.roleName" :value="item.id"></el-option>
  135. </el-select>
  136. </el-form-item>
  137. <el-form-item label="调阅频次" prop="planFrequency">
  138. <el-input type="number" oninput="if(value<=0)value=null;value=parseInt(value)"
  139. v-model.number="form.planFrequency" placeholder="请输入调阅频次"/>
  140. </el-form-item>
  141. <el-form-item label="计划状态" prop="planStatus">
  142. <el-radio-group v-model="form.planStatus">
  143. <el-radio v-for="dict in dict.type.plan_status" :key="dict.value" :label="dict.value">{{ dict.label
  144. }}
  145. </el-radio>
  146. </el-radio-group>
  147. </el-form-item>
  148. <el-form-item label="备注" prop="description">
  149. <el-input v-model="form.description" type="textarea" placeholder="请输入内容"/>
  150. </el-form-item>
  151. </el-form>
  152. <div slot="footer" class="dialog-footer">
  153. <el-button type="primary" @click="submitForm">确 定</el-button>
  154. <el-button @click="cancel">取 消</el-button>
  155. </div>
  156. </DialogCom>
  157. </div>
  158. </template>
  159. <script>
  160. import {listPlan, getPlan, delPlan, addPlan, updatePlan, distribute} from "@/api/core/accessPlan";
  161. import {listRole, findRoleByType, getRole, allRole} from "@/api/system/role";
  162. import tableList from "@/mixins/tableList";
  163. import orgTree from "@/components/orgTree";
  164. import {deptTreeSelect} from "@/api/system/public";
  165. import KFileUpload from "@/components/K-FileUpload/index.vue";
  166. export default {
  167. name: "Plan",
  168. dicts: ['sys_org_type', 'sys_access_cycle', 'sys_normal_disable', 'plan_status'],
  169. components: {
  170. orgTree
  171. },
  172. data() {
  173. return {
  174. startDatepickerOptions: {
  175. disabledDate(time) {
  176. const date = new Date();
  177. date.setTime(date.getTime() - 3600 * 1000 * 24);
  178. return time.getTime() < date;
  179. },
  180. },
  181. endDatepickerOptions: {
  182. disabledDate: this.disabledDate
  183. },
  184. // 遮罩层
  185. loading: true,
  186. // 选中数组
  187. ids: [],
  188. names: [],
  189. // 非单个禁用
  190. single: true,
  191. // 非多个禁用
  192. multiple: true,
  193. // 显示搜索条件
  194. showSearch: true,
  195. // 总条数
  196. total: 0,
  197. // 监控调阅计划表格数据
  198. planList: [],
  199. check:null,
  200. //角色列表
  201. roleList: [],
  202. // 弹出层标题
  203. title: "",
  204. // 是否显示弹出层
  205. open: false,
  206. // 查询参数
  207. queryParams: {
  208. pageNum: 1,
  209. pageSize: 10,
  210. planName: null,
  211. orgId: null,
  212. orgPath: null,
  213. orgName: null,
  214. orgType: null,
  215. roleId: null,
  216. planCycle: null,
  217. planFrequency: null,
  218. planStatus: null,
  219. description: null,
  220. isDeleted: null,
  221. isDistribute: null,
  222. checkSub: true
  223. },
  224. // 表单参数
  225. form: {},
  226. // 表单校验
  227. rules: {
  228. planName: [
  229. {required: true, message: '请输入计划名称', trigger: 'change'},
  230. ],
  231. orgType: [
  232. {required: true, message: '请选择机构类型', trigger: 'change'},
  233. ],
  234. planCycle: [
  235. {required: true, message: '请选择调阅周期', trigger: 'change'},
  236. ],
  237. roleId: [
  238. {required: true, message: '请选择调阅角色', trigger: 'change'},
  239. ],
  240. planFrequency: [
  241. {required: true, message: '请选择调阅频次', trigger: 'change'},
  242. ],
  243. }
  244. };
  245. },
  246. created() {
  247. // this.getList();
  248. // listRole().then(response => {
  249. // this.roleList = response.rows;
  250. // });
  251. allRole().then(response => {
  252. this.roleList = response.data;
  253. });
  254. },
  255. methods: {
  256. getPageIndex($index) {
  257. //表格序号
  258. return (
  259. (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
  260. );
  261. },
  262. /** 查询监控调阅计划列表 */
  263. getList() {
  264. this.loading = true;
  265. listPlan(this.queryParams).then(response => {
  266. this.planList = response.data.rows;
  267. this.check=response.check;
  268. this.total = response.data.total;
  269. this.loading = false;
  270. });
  271. },
  272. // 取消按钮
  273. cancel() {
  274. this.open = false;
  275. this.reset();
  276. },
  277. // 表单重置
  278. reset() {
  279. this.form = {
  280. id: null,
  281. planName: null,
  282. orgId: null,
  283. orgPath: null,
  284. orgName: null,
  285. orgType: null,
  286. roleId: null,
  287. planCycle: null,
  288. planFrequency: null,
  289. planStatus: "0",
  290. createTime: null,
  291. createBy: null,
  292. updateTime: null,
  293. updateBy: null,
  294. description: null,
  295. isDeleted: null
  296. };
  297. this.resetForm("form");
  298. },
  299. getDefaultKey(key) {
  300. this.queryParams.orgId = key;
  301. this.getList();
  302. },
  303. //单选框状态改变
  304. checkChange(state) {
  305. this.queryParams.checkSub = state;
  306. this.handleQuery();
  307. },
  308. startDateChanged(time) {
  309. if (this.form.startTime > this.form.endTime) {
  310. this.form.endTime = this.form.startTime;
  311. }
  312. },
  313. disabledDate(time) {
  314. //小于开始日期禁止选择
  315. let startTime = new Date();
  316. startTime.setTime(startTime.getTime() - 3600 * 1000 * 24);
  317. if (this.form.startTime) {
  318. startTime = new Date(this.formatTime(this.form.startTime, 'YYYY-MM-DD'));
  319. startTime.setTime(startTime.getTime() - 3600 * 1000 * 24);
  320. }
  321. return time.getTime() < new Date(startTime).getTime()
  322. },
  323. /** 搜索按钮操作 */
  324. handleQuery() {
  325. this.queryParams.pageNum = 1;
  326. this.getList();
  327. },
  328. // 节点单击事件
  329. clickTreeNode(data) {
  330. //this.initPlanRoleList();
  331. this.queryParams.orgId = data.id;
  332. this.handleQuery();
  333. },
  334. changeSelectOrgType(val) {
  335. getRole(val).then(response => {
  336. this.form.orgType = response.data.orgType;
  337. })
  338. },
  339. changeSelect(val) {
  340. findRoleByType(val).then(response => {
  341. this.roleList = response;
  342. this.queryParams.roleId=null;
  343. this.form.roleId=null;
  344. })
  345. },
  346. /** 查询机构树数据 */
  347. getDeptTree() {
  348. deptTreeSelect().then(response => {
  349. this.deptOptions = response.data;
  350. this.handleQuery();
  351. });
  352. },
  353. /** 重置按钮操作 */
  354. resetQuery() {
  355. this.resetForm("queryForm");
  356. this.handleQuery();
  357. allRole().then(response => {
  358. this.roleList = response.data;
  359. });
  360. },
  361. // 多选框选中数据
  362. handleSelectionChange(selection) {
  363. this.ids = selection.map(item => item.id)
  364. this.names = selection.map(item => item.planName)
  365. this.single = selection.length !== 1
  366. this.multiple = !selection.length
  367. },
  368. /** 新增按钮操作 */
  369. handleAdd() {
  370. this.reset();
  371. this.open = true;
  372. this.title = "添加监控调阅计划";
  373. },
  374. /** 修改按钮操作 */
  375. handleUpdate(row) {
  376. this.reset();
  377. const id = row.id || this.ids
  378. getPlan(id).then(response => {
  379. this.form = response.data;
  380. this.open = true;
  381. this.title = "修改监控调阅计划";
  382. findRoleByType(this.form.orgType).then(response => {
  383. this.roleList = response;
  384. })
  385. });
  386. },
  387. /** 提交按钮 */
  388. submitForm() {
  389. this.$refs["form"].validate(valid => {
  390. if (valid) {
  391. if (this.form.id != null) {
  392. updatePlan(this.form).then(response => {
  393. this.$modal.msgSuccess("修改成功");
  394. this.open = false;
  395. this.getList();
  396. });
  397. } else {
  398. addPlan(this.form).then(response => {
  399. this.$modal.msgSuccess("新增成功");
  400. this.open = false;
  401. this.getList();
  402. });
  403. }
  404. }
  405. });
  406. },
  407. /** 删除按钮操作 */
  408. handleDelete(row) {
  409. const ids = row.id || this.ids;
  410. const names = row.planName || this.names;
  411. this.$modal.confirm('是否确认删除监控调阅计划"' + names + '"的数据项?').then(function () {
  412. return delPlan(ids);
  413. }).then(() => {
  414. this.getList();
  415. this.$modal.msgSuccess("删除成功");
  416. }).catch(() => {
  417. });
  418. },
  419. handDistribute(row) {
  420. this.$modal.confirm('是否确认下发监控调阅计划"' + row.planName + '"的数据项?').then(function () {
  421. return distribute(row.id);
  422. }).then(() => {
  423. this.getList();
  424. this.$modal.msgSuccess("下发成功");
  425. }).catch(() => {
  426. });
  427. },
  428. /** 导出按钮操作 */
  429. handleExport() {
  430. this.download('system/plan/export', {
  431. ...this.queryParams
  432. }, `plan_${new Date().getTime()}.xlsx`)
  433. }
  434. }
  435. };
  436. </script>