index.vue 20 KB

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