index.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <!--机构数据-->
  5. <!-- <el-col :span="4" :xs="24">
  6. <org-tree
  7. v-model="queryParams.belongOrgId"
  8. @defaultKey="getDefaultKey"
  9. @checkChange="checkChange"
  10. @click="clickTreeNode"
  11. hangsheTree
  12. :defaultCheckSub="false"
  13. ></org-tree>
  14. </el-col> -->
  15. <!--搜索栏-->
  16. <el-col :span="24" :xs="24">
  17. <div class="main-right-box">
  18. <div class="main-search-box">
  19. <el-form
  20. :model="queryParams"
  21. ref="queryForm"
  22. size="small"
  23. :inline="true"
  24. v-show="showSearch"
  25. >
  26. <el-form-item label="行社名称">
  27. <org-tree
  28. v-model="queryParams.belongOrgId"
  29. @defaultKey="getDefaultKey"
  30. @checkChange="checkChange"
  31. @click="clickTreeNode"
  32. hangsheTree
  33. :defaultCheckSub="false"
  34. ref="orgTree"
  35. ></org-tree>
  36. </el-form-item>
  37. <el-form-item label="任务名称" prop="planName">
  38. <el-input
  39. v-model="queryParams.planName"
  40. placeholder="请输入关键字"
  41. clearable
  42. maxlength="50"
  43. @keyup.enter.native="handleQuery"
  44. />
  45. </el-form-item>
  46. <el-form-item label="机构类型" prop="execOrgType">
  47. <el-select
  48. v-model="queryParams.execOrgType"
  49. placeholder="请选择机构类型"
  50. clearable
  51. >
  52. <el-option
  53. v-for="dict in dict.type.sys_org_type"
  54. :key="dict.value"
  55. :label="dict.label"
  56. :value="dict.value"
  57. />
  58. </el-select>
  59. </el-form-item>
  60. <el-form-item label="任务状态" prop="planStatus">
  61. <el-select
  62. v-model="queryParams.planStatus"
  63. placeholder="请选择任务状态"
  64. clearable
  65. >
  66. <el-option
  67. v-for="dict in dict.type.edu_plan_status"
  68. :key="dict.value"
  69. :label="dict.label"
  70. :value="dict.value"
  71. />
  72. </el-select>
  73. </el-form-item>
  74. <!-- <el-form-item label="培训角色" prop="planRoleId">
  75. <el-select v-model="queryParams.planRoleId" placeholder="请选择培训角色" clearable>
  76. <el-option v-for="item in planRoleList" :key="item.roleId" :label="item.roleName"
  77. :value="item.roleId"></el-option>
  78. </el-select>
  79. </el-form-item>-->
  80. <el-form-item label="任务周期" prop="planCycle">
  81. <el-select
  82. v-model="queryParams.planCycle"
  83. placeholder="请选择任务周期"
  84. clearable
  85. >
  86. <el-option
  87. v-for="dict in dict.type.edu_plan_cycle"
  88. :key="dict.value"
  89. :label="dict.label"
  90. :value="dict.value"
  91. />
  92. </el-select>
  93. </el-form-item>
  94. <!-- <el-form-item>
  95. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  96. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  97. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
  98. v-hasPermi="['core:plan:add']">新增任务
  99. </el-button>
  100. </el-form-item> -->
  101. </el-form>
  102. <el-row :gutter="10">
  103. <el-col :span="1.5">
  104. <el-button
  105. type="primary"
  106. icon="el-icon-search"
  107. size="mini"
  108. @click="handleQuery"
  109. >搜索
  110. </el-button
  111. >
  112. </el-col>
  113. <el-col :span="1.5">
  114. <el-button
  115. type="primary"
  116. icon="el-icon-refresh"
  117. size="mini"
  118. @click="resetQuery"
  119. >重置
  120. </el-button
  121. >
  122. </el-col>
  123. <el-col :span="1.5">
  124. <el-button
  125. type="primary"
  126. icon="el-icon-plus"
  127. size="mini"
  128. @click="handleAdd"
  129. v-hasPermi="['core:plan:add']"
  130. >新增任务
  131. </el-button>
  132. </el-col>
  133. <!-- <el-col :span="1.5">
  134. <el-button type="success" plain icon="el-icon-edit-outline" size="mini" :disabled="single" @click="handleUpdate"
  135. v-hasPermi="['core:plan:edit']">修改
  136. </el-button>
  137. </el-col>
  138. <el-col :span="1.5">
  139. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  140. v-hasPermi="['core:plan:remove']">删除
  141. </el-button>
  142. </el-col>
  143. <el-col :span="1.5">
  144. <el-button
  145. type="warning"
  146. plain
  147. icon="el-icon-download"
  148. size="mini"
  149. @click="handleExport"
  150. v-hasPermi="['core:plan:export']"
  151. >导出
  152. </el-button>
  153. </el-col>-->
  154. <right-toolbar
  155. :showSearch.sync="showSearch"
  156. @queryTable="getList"
  157. ></right-toolbar>
  158. </el-row>
  159. </div>
  160. <el-table
  161. border
  162. height="646"
  163. size="small"
  164. :data="planList"
  165. @selection-change="handleSelectionChange"
  166. row-key="id"
  167. >
  168. <!-- :tree-props="{ children: 'children' }" -->
  169. <el-table-column label="序号" align="center" prop="no" width="60"/>
  170. <el-table-column
  171. label="任务名称"
  172. align="center"
  173. prop="planName"
  174. />
  175. <el-table-column
  176. label="创建机构"
  177. align="center"
  178. prop="createOrgName"
  179. />
  180. <el-table-column
  181. label="行社名称"
  182. align="center"
  183. prop="belongOrgName"
  184. />
  185. <!-- <el-table-column label="所属机构" align="left" width="180" prop="belongOrgName"/> -->
  186. <el-table-column
  187. label="机构类型"
  188. align="center"
  189. width="150"
  190. prop="execOrgType"
  191. >
  192. <template slot-scope="scope">
  193. <dict-tag
  194. :options="dict.type.sys_org_type"
  195. :value="scope.row.execOrgType"
  196. />
  197. </template>
  198. </el-table-column>
  199. <!-- <el-table-column prop="planRoleNameList" width="180" label="培训角色">
  200. <template slot-scope="scope">
  201. <template v-if="scope.row.planRoleNameList">
  202. <el-tag size="mini" type="success"
  203. v-for="(item, index) in (scope.row.planRoleNameList || '').split(',')"
  204. :key="index">
  205. {{ item }}
  206. </el-tag>
  207. </template>
  208. <template v-else>
  209. <el-tag size="mini">{{ scope.row.checkOrgTypeText }}</el-tag>
  210. </template>
  211. </template>
  212. </el-table-column>-->
  213. <el-table-column
  214. label="任务周期"
  215. align="center"
  216. width="150"
  217. prop="planCycle"
  218. >
  219. <template slot-scope="scope">
  220. <dict-tag
  221. :options="dict.type.edu_plan_cycle"
  222. :value="scope.row.planCycle"
  223. />
  224. </template>
  225. </el-table-column>
  226. <el-table-column
  227. label="任务次数"
  228. align="center"
  229. width="100"
  230. prop="execTimes"
  231. />
  232. <el-table-column
  233. label="任务状态"
  234. align="center"
  235. width="100"
  236. prop="planStatus"
  237. >
  238. <template slot-scope="scope">
  239. <dict-tag
  240. :options="dict.type.edu_plan_status"
  241. :value="parseInt(scope.row.planStatus)"
  242. />
  243. </template>
  244. </el-table-column>
  245. <!-- <el-table-column label="备注" align="center" prop="remark"/>-->
  246. <el-table-column
  247. label="操作"
  248. width="200"
  249. align="center"
  250. fixed="right"
  251. class-name="small-padding fixed-width"
  252. >
  253. <template slot-scope="scope">
  254. <el-button
  255. v-if="checkCanPublish(scope.row)"
  256. size="mini"
  257. type="text"
  258. icon="el-icon-arrow-down"
  259. @click="handlePublish(scope.row)"
  260. v-hasPermi="['core:plan:edit']"
  261. >下发
  262. </el-button>
  263. <el-button
  264. v-if="checkCanRevocation(scope.row)"
  265. size="mini"
  266. type="text"
  267. icon="el-icon-top-left"
  268. @click="handleRevocation(scope.row)"
  269. v-hasPermi="['core:plan:edit']"
  270. >撤回
  271. </el-button>
  272. <el-button
  273. v-if="checkCanEdit(scope.row)"
  274. size="mini"
  275. type="text"
  276. icon="el-icon-edit-outline"
  277. @click="handleUpdate(scope.row)"
  278. v-hasPermi="['core:plan:edit']"
  279. >编辑
  280. </el-button>
  281. <el-button
  282. v-if="checkCanDel(scope.row)"
  283. size="mini"
  284. type="text"
  285. icon="el-icon-delete"
  286. @click="handleDelete(scope.row)"
  287. v-hasPermi="['core:plan:remove']"
  288. >删除
  289. </el-button>
  290. </template>
  291. </el-table-column>
  292. </el-table>
  293. <pagination
  294. v-show="total > 0"
  295. :total="total"
  296. :page.sync="queryParams.pageNum"
  297. :limit.sync="queryParams.pageSize"
  298. @pagination="getList"
  299. />
  300. </div>
  301. </el-col>
  302. </el-row>
  303. <!-- 添加或修改教育培训计划对话框 -->
  304. <DialogCom
  305. :title="title"
  306. :visible.sync="open"
  307. :before-close="closeDialog"
  308. @close="cancel"
  309. width="850px"
  310. height="800px"
  311. append-to-body
  312. >
  313. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  314. <el-row>
  315. <el-col :span="24">
  316. <el-form-item label="任务名称" prop="planName" class="endItem">
  317. <el-input
  318. v-model="form.planName"
  319. maxlength="50"
  320. placeholder="请输入任务名称"
  321. />
  322. </el-form-item>
  323. </el-col>
  324. <!-- <el-col :span="12">
  325. <el-form-item label="培训类型" prop="type">
  326. <el-select
  327. style="width: 100%"
  328. v-model="form.type"
  329. placeholder="请选择培训类型"
  330. @change="eduTypeSelected()"
  331. >
  332. <el-option
  333. v-for="dict in dict.type.edu_training_type"
  334. :key="dict.value"
  335. :label="dict.label"
  336. :value="parseInt(dict.value)"
  337. ></el-option>
  338. </el-select>
  339. </el-form-item>
  340. </el-col>-->
  341. </el-row>
  342. <el-row>
  343. <el-col :span="12">
  344. <el-form-item label="任务周期" prop="planCycle">
  345. <el-select
  346. style="width: 100%"
  347. v-model="form.planCycle"
  348. placeholder="请选择任务周期"
  349. :disabled="tableDisable()"
  350. >
  351. <el-option
  352. v-for="dict in dict.type.edu_plan_cycle"
  353. :key="dict.value"
  354. :label="dict.label"
  355. :value="parseInt(dict.value)"
  356. ></el-option>
  357. </el-select>
  358. </el-form-item>
  359. </el-col>
  360. <el-col :span="12">
  361. <el-form-item label="任务次数" prop="execTimes">
  362. <template>
  363. <el-input-number
  364. :disabled="tableDisable()"
  365. style="width: 100%"
  366. v-model="form.execTimes"
  367. :min="1"
  368. :max="10"
  369. ></el-input-number>
  370. </template>
  371. </el-form-item>
  372. </el-col>
  373. <!-- <el-col :span="12">
  374. <el-form-item label="培训角色" prop="planRoleId">
  375. <el-select style="width: 100%" v-model="form.planRoleId" placeholder="请选择" multiple>
  376. <el-option v-for="item in roleList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  377. </el-select>
  378. </el-form-item>
  379. </el-col>-->
  380. </el-row>
  381. <el-row>
  382. <el-col :span="12" v-show="form.planCycle == 0">
  383. <el-form-item prop="startDate" label="开始日期">
  384. <el-date-picker
  385. :disabled="tableDisable()"
  386. style="width: 100%"
  387. v-model="form.startDate"
  388. @change="startDateChanged"
  389. :picker-options="startDatepickerOptions"
  390. align="right"
  391. type="date"
  392. placeholder="选择开始日期"
  393. >
  394. </el-date-picker>
  395. </el-form-item>
  396. </el-col>
  397. <el-col :span="12" v-show="form.planCycle == 0">
  398. <el-form-item prop="endDate" label="结束日期">
  399. <el-date-picker
  400. :disabled="tableDisable()"
  401. style="width: 100%"
  402. v-model="form.endDate"
  403. :picker-options="endDatepickerOptions"
  404. align="right"
  405. type="date"
  406. placeholder="选择结束日期"
  407. >
  408. </el-date-picker>
  409. </el-form-item>
  410. </el-col>
  411. </el-row>
  412. <el-row>
  413. <!-- <el-col :span="12" v-show="showBuildTaskNow()">
  414. <el-form-item label="立即生效" prop="buildTaskNow">
  415. <el-checkbox v-model="form.buildTaskNow">
  416. 默认从下个周期生成任务,
  417. <br/>
  418. 勾选后从当前周期立即生成任务
  419. &lt;!&ndash; <el-popover placement="top-start" title="" width="200" trigger="hover"
  420. content="默认从下个周期生成任务,勾选后从当前周期立即生成任务">
  421. <i class="el-icon-warning-outline change-icon" slot="reference"></i>
  422. </el-popover>&ndash;&gt;
  423. </el-checkbox>
  424. </el-form-item>
  425. </el-col>-->
  426. <el-col :span="12">
  427. <el-form-item label="受训机构类型" prop="execOrgType">
  428. <el-select
  429. style="width: 100%"
  430. v-model="form.execOrgType"
  431. placeholder="请选择受训机构类型"
  432. @change="execOrgTypeChanged()"
  433. :disabled="tableDisable()"
  434. >
  435. <el-option
  436. v-for="dict in getUserOrgType"
  437. :key="dict.value"
  438. :label="dict.label"
  439. :value="parseInt(dict.value)"
  440. ></el-option>
  441. </el-select>
  442. </el-form-item>
  443. </el-col>
  444. <!-- <el-col :span="12">
  445. <el-form-item v-if="this.form.id" label="计划状态" prop="planStatus">
  446. <el-select style="width: 100%" v-model="form.planStatus" placeholder="请选择计划状态">
  447. <el-option v-for="dict in dict.type.edu_plan_status" :key="dict.value" :label="dict.label"
  448. :value="parseInt(dict.value)"></el-option>
  449. </el-select>
  450. </el-form-item>
  451. </el-col>-->
  452. <el-col :span="12">
  453. <el-form-item
  454. v-show="form.execOrgType"
  455. label="受训机构"
  456. prop="planExecOrgIdList"
  457. >
  458. <org-tree-select
  459. v-model="form.planExecOrgIdList"
  460. :queryData="form.execOrgType"
  461. ref="orgTreeSelect"
  462. :enabledCheckOrgTypes="form.execOrgType"
  463. :disabled="tableDisable()"
  464. >
  465. </org-tree-select>
  466. </el-form-item>
  467. </el-col>
  468. </el-row>
  469. <el-row>
  470. <el-col :span="24">
  471. <el-form-item label="备注" prop="remark">
  472. <k-textarea
  473. v-model="form.remark"
  474. :length="200"
  475. :autosize="{ minRows: 2, maxRows: 4 }"
  476. type="textarea"
  477. show-word-limit
  478. placeholder="请输入备注"
  479. :disabled="tableDisable()"
  480. />
  481. </el-form-item>
  482. </el-col>
  483. </el-row>
  484. <el-row>
  485. <el-col :span="12">
  486. <el-form-item label="上传文件" prop="fileList">
  487. <K-file-upload
  488. :disabled="tableDisable()"
  489. ref="upload"
  490. :defaultValue="formFileListDefualtValue"
  491. v-model="form.fileList"
  492. />
  493. </el-form-item>
  494. </el-col>
  495. <el-col :span="12">
  496. <el-form-item label="">
  497. <el-button type="primary" @click="showSelectFile" v-if="!tableDisable()"
  498. >选取知识库文件
  499. </el-button
  500. >
  501. </el-form-item>
  502. </el-col>
  503. </el-row>
  504. </el-form>
  505. <div slot="footer" class="dialog-footer">
  506. <el-button type="primary" @click="submitForm">确 定</el-button>
  507. <el-button @click="cancel">取 消</el-button>
  508. </div>
  509. </DialogCom>
  510. <DialogSelectFile ref="DialogSelectFile" :defaultSelect="defaultSelect" @select="fileSelected"
  511. :orgId="orgId"></DialogSelectFile>
  512. <DialogThreeState ref="DialogThreeState"></DialogThreeState>
  513. </div>
  514. </template>
  515. <script>
  516. import {
  517. addPlan,
  518. delPlan,
  519. getPlan,
  520. listPlan,
  521. listPlanRole,
  522. publishPlan,
  523. roleList,
  524. updatePlan,
  525. revocationPlan,
  526. } from "@/api/core/edu/plan";
  527. import OrgTreeSelect from "@/components/orgTreeSelect";
  528. import tableList from "@/mixins/tableList";
  529. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  530. import {deptTreeSelect} from "@/api/system/public";
  531. import KFileUpload from "@/components/K-FileUpload/index.vue";
  532. import DialogSelectFile from "./dialog.select.file.vue";
  533. import dayjs from "dayjs";
  534. import KTextarea from "@/components/common/textarea.vue";
  535. import {mapGetters} from "vuex";
  536. import DialogThreeState from "@/components/message/threeStateMessageBox.vue";
  537. import * as api from "@/api/resumption/plan";
  538. export default {
  539. name: "Plan",
  540. dicts: [
  541. "sys_org_type",
  542. "edu_plan_cycle",
  543. "edu_plan_status",
  544. "edu_training_type",
  545. ],
  546. components: {
  547. OrgTreeSelect,
  548. OrgTree,
  549. KFileUpload,
  550. DialogSelectFile,
  551. KTextarea,
  552. DialogThreeState,
  553. },
  554. mixins: [tableList],
  555. data() {
  556. return {
  557. // 遮罩层
  558. loading: true,
  559. // 选中数组
  560. ids: [],
  561. // 非单个停用
  562. single: true,
  563. // 非多个停用
  564. multiple: true,
  565. // 显示搜索条件
  566. showSearch: true,
  567. // 总条数
  568. total: 0,
  569. // 教育培训计划表格数据
  570. planList: [],
  571. // 弹出层标题
  572. title: "",
  573. // 是否显示弹出层
  574. open: false,
  575. isUnfold: false,
  576. defaultSelect: [],
  577. filterOrtTypeOptions: [],
  578. type: null,
  579. // 查询参数
  580. queryParams: {
  581. execOrgType: null,
  582. planCycle: null,
  583. planStatus: null,
  584. planRoleId: null,
  585. planName: null,
  586. pageNum: 1,
  587. pageSize: 10,
  588. belongOrgId: null,
  589. checkSub: false,
  590. },
  591. formFileListDefualtValue: [],
  592. // 表单参数
  593. form: {},
  594. // 表单校验
  595. rules: {
  596. planName: [
  597. {required: true, message: "任务名称不能为空", trigger: "blur"},
  598. ],
  599. type: [
  600. {required: true, message: "培训类型不能为空", trigger: "blur"},
  601. ],
  602. planCycle: [
  603. {required: true, message: "任务周期不能为空", trigger: "blur"},
  604. ],
  605. execTimes: [
  606. {required: true, message: "培训次数不能为空", trigger: "blur"},
  607. ],
  608. planStatus: [
  609. {required: true, message: "计划状态不能为空", trigger: "blur"},
  610. ],
  611. execOrgType: [
  612. {required: true, message: "受训机构类型不能为空", trigger: "blur"},
  613. ],
  614. planRoleId: [
  615. {required: true, message: "培训角色不能为空", trigger: "blur"},
  616. ],
  617. },
  618. planRoleList: [],
  619. roleList: [],
  620. //修改新增中的机构树
  621. deptOptions: [],
  622. startDatepickerOptions: {
  623. disabledDate(time) {
  624. const date = new Date();
  625. date.setTime(date.getTime() - 3600 * 1000 * 24);
  626. return time.getTime() < date;
  627. },
  628. },
  629. endDatepickerOptions: {
  630. disabledDate: this.disabledDate,
  631. },
  632. };
  633. },
  634. computed: {
  635. ...mapGetters(["orgId"]),
  636. getUserOrgType() {
  637. let tempArry = [];
  638. this.dict.type.sys_org_type.forEach((x) => {
  639. if (Number(x.value) >= this.$store.getters.orgType && (x.value != 7 && x.value != 8)) {
  640. tempArry.push(x);
  641. }
  642. });
  643. // console.log("computed getUserOrgType",tempArry);
  644. return tempArry;
  645. },
  646. },
  647. created() {
  648. //this.getList();
  649. // this.initPlanRoleList();
  650. },
  651. methods: {
  652. // clear() {
  653. // this.$refs['orgTreeSelect'].clear();
  654. // },
  655. queryNode(nodes) {
  656. this.form.planExecOrgIdList = JSON.parse(nodes).map((v) => {
  657. return v.id;
  658. });
  659. },
  660. showBuildTaskNow() {
  661. //如果是新增的情况下
  662. if (!this.form.id) {
  663. return this.form.planCycle != 0;
  664. } else {
  665. //如果是编辑的情况下,判断是否是标准计划
  666. /*if (this.form.standard==1){
  667. return this.form.planCycle != 0&&this.form.issue == 0
  668. }*/
  669. return this.form.planStatus == 0 && this.form.planCycle != 0;
  670. }
  671. },
  672. /** 查询教育培训计划列表 */
  673. getList() {
  674. this.loading = true;
  675. listPlan(this.queryParams).then((response) => {
  676. this.planList = response.rows;
  677. this.total = response.total;
  678. this.loading = false;
  679. });
  680. },
  681. //初始化与计划相关的角色信息
  682. initPlanRoleList() {
  683. listPlanRole({}).then((response) => {
  684. this.planRoleList = response.data;
  685. });
  686. },
  687. //初始化所有角色数据
  688. initRoleList(query) {
  689. this.form.planRoleId = [];
  690. roleList(query).then((response) => {
  691. this.roleList = response.data;
  692. });
  693. },
  694. startDateChanged(time) {
  695. if (this.form.startDate > this.form.endDate) {
  696. this.form.endDate = this.form.startDate;
  697. }
  698. },
  699. disabledDate(time) {
  700. //小于开始日期禁止选择
  701. let startDate = new Date();
  702. startDate.setTime(startDate.getTime() - 3600 * 1000 * 24);
  703. if (this.form.startDate) {
  704. startDate = new Date(
  705. this.formatTime(this.form.startDate, "YYYY-MM-DD")
  706. );
  707. startDate.setTime(startDate.getTime() - 3600 * 1000 * 24);
  708. }
  709. return time.getTime() < new Date(startDate).getTime();
  710. },
  711. tableDisable(){
  712. return this.form.planStatus==1;
  713. },
  714. checkCanPublish(row) {
  715. //是标准计划且未下发,状态为草稿或停用,且所属机构为当前用户登录机构时才显示 “下发”按钮
  716. if (
  717. row.issue == 0 &&
  718. row.standard == 1 &&
  719. (row.planStatus == 0 || row.planStatus == 2) &&
  720. this.checkCanEdit(row)
  721. ) {
  722. return true;
  723. }
  724. return false;
  725. },
  726. //撤回按钮
  727. checkCanRevocation(row) {
  728. return row.planStatus == 1 && row.standard == 1 && this.checkCanEdit(row);
  729. },
  730. //所属机构为当前用户登录机构或等于创建机构时才显示 “编辑、删除”按钮
  731. checkCanEdit(row) {
  732. return (
  733. row.belongOrgId == this.$store.getters.orgId
  734. );
  735. },
  736. checkCanDel(row) {
  737. // 计划仅能够通过删除标准计划来删除
  738. /* return (row.belongOrgId == this.$store.getters.orgId)
  739. /!* && (row.issue != 1 || (row.issue == 1 && row.done != 1))*!/
  740. && !row.parentId && row.createByTopOrg!=1*/
  741. return (
  742. (row.standard == 1 || row.standard == 2) && /*row.done != 1 &&*/
  743. this.checkCanEdit(row)
  744. );
  745. },
  746. //省联社下发的计划不显示“删除”按钮
  747. checkCreateByTopOrg(row) {
  748. return row.createByTopOrg !== 1 && this.checkCanEdit(row);
  749. },
  750. eduTypeSelected() {
  751. if (this.form.type == 0) {
  752. this.form.planCycle = 3;
  753. this.form.execTimes = 1;
  754. this.form.execOrgType = 3;
  755. }
  756. if (this.form.type == 1) {
  757. this.form.planCycle = 6;
  758. this.form.execTimes = 2;
  759. this.form.execOrgType = 3;
  760. }
  761. if (this.form.type == 2) {
  762. this.form.planCycle = 4;
  763. this.form.execTimes = 1;
  764. this.form.execOrgType = 4;
  765. }
  766. if (this.form.type == 3) {
  767. this.form.planCycle = 6;
  768. this.form.execTimes = 2;
  769. this.form.execOrgType = 4;
  770. }
  771. },
  772. execOrgTypeChanged(row) {
  773. this.$refs["orgTreeSelect"].clear();
  774. //this.initRoleList(this.form.execOrgType);
  775. // this.form.planExecOrgIdList = [];
  776. },
  777. /** 查询机构树数据 */
  778. getDeptTree() {
  779. deptTreeSelect().then((response) => {
  780. this.deptOptions = response.data;
  781. });
  782. },
  783. // 取消按钮
  784. cancel() {
  785. //console.log("xxx")
  786. this.open = false;
  787. this.reset();
  788. this.$refs["orgTreeSelect"].clear();
  789. this.$refs["upload"].clearFiles();
  790. },
  791. closeDialog() {
  792. this.cancel();
  793. },
  794. // 表单重置
  795. reset() {
  796. this.form = {
  797. id: null,
  798. type: null,
  799. planName: null,
  800. planCycle: null,
  801. execTimes: null,
  802. planStatus: null,
  803. execOrgType: null,
  804. planExecOrgIdList: [],
  805. startDate: null,
  806. endDate: null,
  807. buildTaskNow: null,
  808. remark: null,
  809. planRoleId: null,
  810. fileList: null,
  811. standard: null,
  812. done: null,
  813. };
  814. this.resetForm("form");
  815. },
  816. getDefaultKey(key) {
  817. this.queryParams.belongOrgId = key;
  818. this.getList();
  819. },
  820. //单选框状态改变
  821. checkChange(state) {
  822. this.queryParams.checkSub = state;
  823. this.handleQuery();
  824. },
  825. // 节点单击事件
  826. clickTreeNode(data) {
  827. // this.initPlanRoleList();
  828. this.queryParams.belongOrgId = data.id;
  829. this.handleQuery();
  830. },
  831. /** treeSelect组件自定义数据*/
  832. tenantIdnormalizer(node, instanceId) {
  833. if (node.children && !node.children.length) {
  834. delete node.children;
  835. }
  836. return {
  837. id: node.id,
  838. label: node.name,
  839. children: node.children,
  840. };
  841. },
  842. /** 搜索按钮操作 */
  843. handleQuery() {
  844. this.queryParams.pageNum = 1;
  845. this.getList();
  846. },
  847. /** 重置按钮操作 */
  848. resetQuery() {
  849. this.resetForm("queryForm");
  850. this.queryParams.belongOrgId = this.orgId
  851. this.queryParams.checkSub = false;
  852. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub)
  853. this.handleQuery();
  854. },
  855. // 多选框选中数据
  856. handleSelectionChange(selection) {
  857. this.ids = selection.map((item) => item.id);
  858. this.single = selection.length !== 1;
  859. this.multiple = !selection.length;
  860. },
  861. /** 新增按钮操作 */
  862. handleAdd() {
  863. this.initRoleList();
  864. this.reset();
  865. this.open = true;
  866. this.title = "新增培训任务";
  867. },
  868. /** 修改按钮操作 */
  869. handleUpdate(row) {
  870. this.initRoleList();
  871. this.reset();
  872. const id = row.id || this.ids;
  873. getPlan(id).then((response) => {
  874. this.form = response.data;
  875. //将 this.form.planExecOrgIdList中的元素转为字符串
  876. if (this.form.planExecOrgIdList == null) {
  877. this.form.planExecOrgIdList = [];
  878. }
  879. this.form.planExecOrgIdList = this.form.planExecOrgIdList.map(
  880. (element) => element.toString()
  881. );
  882. this.formFileListDefualtValue = this.form.fileList;
  883. this.open = true;
  884. this.title = "编辑培训任务";
  885. });
  886. },
  887. /** 提交按钮 */
  888. submitForm() {
  889. if (dayjs(this.form.startDate).isAfter(dayjs(this.form.endDate))) {
  890. this.$message.error("开始时间不能大于结束时间!");
  891. return;
  892. }
  893. this.$refs["form"].validate((valid) => {
  894. if (valid) {
  895. let request = {...this.form};
  896. if (this.form.planExecOrgIdList) {
  897. const list = Array.isArray(this.form.planExecOrgIdList)
  898. ? this.form.planExecOrgIdList
  899. : [this.form.planExecOrgIdList];
  900. request.planExecOrgIdList = list;
  901. } else {
  902. request.planExecOrgIdList = [];
  903. }
  904. if (request.id != null) {
  905. let msg = "";
  906. if (this.form.planStatus == 1) {
  907. if (this.form.done == 1) {
  908. msg = "因存在已完成任务,本次修改内容将从下周期生效";
  909. } else {
  910. msg = "因不存在已完成任务,本次修改内容将立即生效";
  911. }
  912. } else {
  913. msg = "是否确认修改?";
  914. }
  915. this.$modal
  916. .confirm(msg)
  917. .then(function () {
  918. return updatePlan(request);
  919. })
  920. .then(() => {
  921. this.$modal.msgSuccess("修改成功");
  922. this.open = false;
  923. this.getList();
  924. this.$refs["upload"].clearFiles();
  925. })
  926. .catch(() => {
  927. });
  928. } else {
  929. addPlan(request).then((response) => {
  930. this.$modal.msgSuccess("新增成功");
  931. this.open = false;
  932. this.getList();
  933. this.$refs["upload"].clearFiles();
  934. });
  935. }
  936. }
  937. });
  938. },
  939. /** 删除按钮操作 */
  940. handleDelete(row) {
  941. let msg = "";
  942. if (row.planStatus == 0) {
  943. msg = '是否确认删除名称为"' + row.planName + '"的任务?';
  944. } else if (row.planStatus == 1) {
  945. if (row.planCycle == 1) {
  946. msg = "本次删除将强制删除今日所有任务?";
  947. } else {
  948. msg = "本次删除将强制删除当前任务时间及以后所有任务";
  949. }
  950. } else if (row.planStatus == 2) {
  951. if (row.planCycle == 1) {
  952. msg = "本次删除将强制删除今日所有任务";
  953. } else {
  954. msg = "本次删除将强制删除当前任务时间及以后所有任务";
  955. }
  956. }
  957. const ids = row.id || this.ids;
  958. this.$modal
  959. .confirm(msg)
  960. .then(function () {
  961. return delPlan(ids);
  962. })
  963. .then(() => {
  964. this.getList();
  965. this.$modal.msgSuccess("删除成功");
  966. })
  967. .catch(() => {
  968. });
  969. },
  970. /** 下发计划 */
  971. handlePublish(row) {
  972. let msg = "";
  973. if (row.planCycle == 0) {
  974. this.$modal
  975. .confirm("无周期任务下发将会立即生成任务,是否确认下发?", {
  976. confirmButtonText: "确认下发",
  977. canelButtonText: "取消下发",
  978. })
  979. .then(() => {
  980. publishPlan(row.id, 1);
  981. this.delayFlush(200)
  982. });
  983. } else {
  984. if (row.planStatus == 0) {
  985. msg = "请选择下发后立即生成或下周期生成任务?";
  986. this.$refs["DialogThreeState"].show(
  987. msg,
  988. (state) => {
  989. if (state == 0 || state == 1) {
  990. publishPlan(row.id, state);
  991. this.delayFlush(200)
  992. }
  993. },
  994. {
  995. yesText: "立即生成",//1
  996. noText: "下周期",//0
  997. cancelText: "取消下发",
  998. }
  999. );
  1000. } else if (row.planStatus == 2) {
  1001. this.$modal
  1002. .confirm("因存在已完成任务,是否确定从下周期生成任务", {
  1003. confirmButtonText: "确定",
  1004. canelButtonText: "取消下发",
  1005. })
  1006. .then(() => {
  1007. publishPlan(row.id, 0);
  1008. this.delayFlush(200)
  1009. });
  1010. }
  1011. }
  1012. },
  1013. delayFlush(time) {
  1014. setTimeout(() => {
  1015. this.getList()
  1016. }, time)
  1017. },
  1018. getMsgStr(row, type) {
  1019. let str = "是否确认" + type + "该计划?";
  1020. if (row.standard == 1) {
  1021. str = "此操作将会影响所有行社计划," + str;
  1022. }
  1023. return str;
  1024. },
  1025. //撤回计划
  1026. handleRevocation(row) {
  1027. let msg = "";
  1028. //无周期
  1029. if (row.planCycle == 0) {
  1030. if (row.done == 1) {
  1031. msg = '因存在已完成任务,无周期任务不允许撤回,如需删除下发任务请点击"删除"';
  1032. this.$alert(msg, '系统提示', {
  1033. confirmButtonText: "确认"
  1034. })
  1035. return
  1036. } else {
  1037. msg = "因存在不已完成任务,撤回后将删除所有生成任务";
  1038. }
  1039. } else {
  1040. //有周期
  1041. if (row.done == 1) {
  1042. msg =
  1043. "因存在已完成任务,撤回后下周期起将不再生成任务";
  1044. } else {
  1045. msg = "因存在不已完成任务,撤回后将删除所有生成任务";
  1046. }
  1047. }
  1048. this.$modal
  1049. .confirm(msg, "提示")
  1050. .then(() => {
  1051. // 用户点击了确认按钮
  1052. this.loading = true;
  1053. revocationPlan(row.id).then((response) => {
  1054. this.getList();
  1055. this.loading = false;
  1056. });
  1057. })
  1058. .catch(() => {
  1059. // 用户点击了取消按钮
  1060. });
  1061. },
  1062. /** 导出按钮操作 */
  1063. handleExport() {
  1064. this.download(
  1065. "system/plan/export",
  1066. {
  1067. ...this.queryParams,
  1068. },
  1069. `plan_${new Date().getTime()}.xlsx`
  1070. );
  1071. },
  1072. showSelectFile() {
  1073. this.$refs["DialogSelectFile"].show();
  1074. },
  1075. fileSelected(list) {
  1076. if (!list) return;
  1077. let tempArry = [];
  1078. let fileNameList = [];
  1079. let addFileNameList = [];
  1080. if (this.form.fileList == null) {
  1081. this.form.fileList = [];
  1082. }
  1083. this.form.fileList.forEach((x) => {
  1084. let fileObj = JSON.parse(x);
  1085. fileNameList.push(fileObj.name);
  1086. });
  1087. list.forEach((x) => {
  1088. tempArry.forEach((s) => {
  1089. addFileNameList.push(JSON.parse(s).name);
  1090. });
  1091. x.fileList.forEach((y) => {
  1092. let fileObj = JSON.parse(y);
  1093. if (
  1094. fileNameList.indexOf(fileObj.name) == -1 &&
  1095. addFileNameList.indexOf(fileObj.name) == -1
  1096. ) {
  1097. tempArry.push(y);
  1098. }
  1099. });
  1100. });
  1101. if (this.form.fileList) {
  1102. this.formFileListDefualtValue = this.form.fileList.concat(tempArry);
  1103. } else {
  1104. this.formFileListDefualtValue = tempArry;
  1105. }
  1106. },
  1107. },
  1108. mounted() {
  1109. // console.log("mounted",this.$options.dicts);
  1110. // let a= this.getSysOrgType;
  1111. // console.log(" handleAdd getSysOrgType",a);
  1112. },
  1113. // updated(){
  1114. // console.log("update",this.$options.dicts);
  1115. // },
  1116. };
  1117. </script>
  1118. <style lang="scss" scoped>
  1119. .endItem ::v-deep .el-textarea__inner {
  1120. padding-bottom: 36px;
  1121. }
  1122. </style>