index.vue 19 KB

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