index.vue 19 KB

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