index.vue 33 KB

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