index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item :label="$t('年份')" prop="year">
  5. <el-date-picker clearable size="small" style="width: 200px"
  6. v-model="queryParams.year"
  7. type="year"
  8. value-format="yyyy"
  9. :placeholder="$t('请选择') + $t('年份')"
  10. @input="handleQuery">
  11. </el-date-picker>
  12. </el-form-item>
  13. <el-form-item :label="$t('课程名称')" prop="item">
  14. <el-input
  15. v-model="queryParams.item"
  16. :placeholder="$t('请输入') + $t('课程名称')"
  17. clearable
  18. size="small"
  19. @input="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('搜索') }}</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <el-col :span="1.5">
  29. <el-button
  30. type="primary"
  31. icon="el-icon-plus"
  32. size="mini"
  33. @click="handleAdd"
  34. v-hasPermi="['training:regular:add']"
  35. >{{ $t('新增') }}</el-button>
  36. </el-col>
  37. <el-col :span="1.5">
  38. <el-button
  39. type="success"
  40. icon="el-icon-edit"
  41. size="mini"
  42. :disabled="single"
  43. @click="handleUpdate"
  44. v-hasPermi="['training:regular:edit']"
  45. >{{ $t('修改') }}</el-button>
  46. </el-col>
  47. <el-col :span="1.5">
  48. <el-button
  49. type="danger"
  50. icon="el-icon-delete"
  51. size="mini"
  52. :disabled="multiple"
  53. @click="handleDelete"
  54. v-hasPermi="['training:regular:remove']"
  55. >{{ $t('删除') }}</el-button>
  56. </el-col>
  57. <!--<el-col :span="1.5">
  58. <el-button
  59. type="info"
  60. icon="el-icon-upload2"
  61. size="mini"
  62. @click="handleImport"
  63. v-hasPermi="['training:regular:edit']"
  64. >导入</el-button>
  65. </el-col>
  66. <el-col :span="1.5">
  67. <el-button
  68. type="warning"
  69. icon="el-icon-download"
  70. size="mini"
  71. @click="handleExport"
  72. v-hasPermi="['training:regular:export']"
  73. >{{ $t('导出') }}</el-button>
  74. </el-col>-->
  75. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  76. </el-row>
  77. <el-row class="colorMark">
  78. <svg-icon icon-class="rectangleLightgreen" class="rectangleLightgreen"></svg-icon>{{ $t('需要培训') }}
  79. <svg-icon icon-class="rectangleFlesh" class="rectangleFlesh"></svg-icon>{{ $t('指定人员') }}
  80. <svg-icon icon-class="rectangleYellow" class="rectangleYellow"></svg-icon>{{ $t('当被此项目涉及到时,如MOC、事件调查,需要培训') }}
  81. </el-row>
  82. <el-table ref="regularTable" v-loading="loading" :data="regularList" @selection-change="handleSelectionChange" :cell-class-name="tableCellClassName" :height="clientHeight" border>
  83. <el-table-column type="selection" width="55" align="center" />
  84. <el-table-column :label="$t('年份')" align="center" prop="year" width="50" :show-overflow-tooltip="true"/>
  85. <el-table-column :label="$t('课程代码')" align="center" prop="courseCode" width="150" :show-overflow-tooltip="true"/>
  86. <el-table-column :label="$t('课程名称')" align="center" prop="item" width="350" :show-overflow-tooltip="true"/>
  87. <el-table-column :label="$t('计划培训时间')" align="center" prop="planTrainingdate" width="100">
  88. <template slot-scope="scope">
  89. <span v-if="scope.row.notPlan === 'false'">{{ scope.row.notTrainingdate }}</span>
  90. <span v-else>{{ scope.row.planTrainingdate }}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column :label="$t('授课人')" align="center" prop="lecturerName" width="230" :show-overflow-tooltip="true" />
  94. <el-table-column :label="$t('课时')" align="center" prop="hour" :show-overflow-tooltip="true"/>
  95. <el-table-column v-for="(item, index) in actualpostIdOptions" width="150" :label="item.dictLabel" :key="index" align="center">
  96. <template slot-scope="scope">
  97. {{scope.row.actualpost[index]}}
  98. </template>
  99. </el-table-column>
  100. <el-table-column :label="$t('备注')" align="center" prop="remarks" width="300" :show-overflow-tooltip="true"/>
  101. <el-table-column :label="$t('操作')" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  102. <template slot-scope="scope">
  103. <el-button
  104. size="mini"
  105. type="text"
  106. icon="el-icon-edit"
  107. @click="handleUpdate(scope.row)"
  108. v-hasPermi="['training:regular:edit']"
  109. >{{ $t('修改') }}</el-button>
  110. <el-button
  111. size="mini"
  112. type="text"
  113. icon="el-icon-delete"
  114. @click="handleDelete(scope.row)"
  115. v-hasPermi="['training:regular:remove']"
  116. >{{ $t('删除') }}</el-button>
  117. </template>
  118. </el-table-column>
  119. </el-table>
  120. <pagination
  121. v-show="total>0"
  122. :total="total"
  123. :page.sync="queryParams.pageNum"
  124. :limit.sync="queryParams.pageSize"
  125. @pagination="getList"
  126. />
  127. <!-- 添加或修改装置培训计划对话框 -->
  128. <el-dialog v-dialogDrag :title="title" :visible.sync="open" width="500px" append-to-body>
  129. <el-form ref="form" :model="form" :rules="rules" label-width="130px">
  130. <el-form-item :label="$t('年份')" prop="year">
  131. <el-date-picker clearable size="small" style="width: 200px"
  132. v-model="form.year"
  133. type="year"
  134. value-format="yyyy"
  135. @change="getLecturer"
  136. :placeholder="$t('请选择') + $t('年份')">
  137. </el-date-picker>
  138. </el-form-item>
  139. <el-form-item :label="$t('课程代码')" prop="courseCode">
  140. <el-input v-model="form.courseCode" :placeholder="$t('请输入') + $t('课程代码')" />
  141. </el-form-item>
  142. <el-form-item :label="$t('课程名称')" prop="item">
  143. <el-input v-model="form.item" :placeholder="$t('请输入') + $t('课程名称')" />
  144. </el-form-item>
  145. <el-form-item :label="$t('需参培岗位')" prop="actualpostId">
  146. <el-select v-model="actualpostIds" multiple :placeholder="$t('请选择') + $t('需参培岗位')" @change="changeActualpost">
  147. <el-option
  148. v-for="dict in actualpostOptions"
  149. :key="dict.dictValue"
  150. :label="dict.dictLabel"
  151. :value="dict.dictValue"
  152. ></el-option>
  153. </el-select>
  154. </el-form-item>
  155. <el-form-item :label="$t('是否存在')+$t('空格') +$t('指定人员')" prop="haveDesignated">
  156. <el-checkbox v-model="haveDesignated"></el-checkbox>
  157. </el-form-item>
  158. <el-form-item :label="$t('指定人员')+$t('空格') + $t('岗位')" prop="designatedPosition" v-if="haveDesignated === true">
  159. <el-select v-model="designatedPositions" multiple :placeholder="$t('请选择') + $t('指定岗位')" @change="changeDesignated">
  160. <el-option
  161. v-for="dict in designatedPositionOptions"
  162. :key="dict.dictValue"
  163. :label="dict.dictLabel"
  164. :value="dict.dictValue"
  165. ></el-option>
  166. </el-select>
  167. </el-form-item>
  168. <el-form-item :label="$t('指定人员')" prop="designatedStaff" v-if="haveDesignated === true && designatedPositions.length > 0">
  169. <el-select v-model="designatedStaffs" filterable multiple :placeholder="$t('请选择') + $t('指定人员')">
  170. <el-option
  171. v-for="dict in stffmgrOptions"
  172. :key="dict.staffid"
  173. :label="dict.name"
  174. :value="dict.staffid">
  175. <span style="float: left">{{ dict.name }}</span>
  176. <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.staffid }}</span>
  177. </el-option>
  178. </el-select>
  179. </el-form-item>
  180. <el-form-item :label="$t('是否涉及') + $t('其他部门')" prop="involvedMoc">
  181. <el-checkbox v-model="form.involvedMoc" @change="changeInvolved"></el-checkbox>
  182. </el-form-item>
  183. <el-form-item :label="$t('指定其他部门')" prop="designatedOther" v-if="form.involvedMoc === true">
  184. <el-select v-model="otherPositions" multiple :placeholder="$t('请选择') + $t('其他部门')">
  185. <el-option
  186. v-for="dict in otherPositionOptions"
  187. :key="dict.dictValue"
  188. :label="dict.dictLabel"
  189. :value="dict.dictValue"
  190. ></el-option>
  191. </el-select>
  192. </el-form-item>
  193. <el-form-item :label="$t('备注')" prop="remarks">
  194. <el-input v-model="form.remarks" :placeholder="$t('请输入') + $t('备注')" />
  195. </el-form-item>
  196. <el-form-item :label="$t('是否') + $t('计划培训时间')" prop="notPlan">
  197. <el-checkbox v-model="form.notPlan"></el-checkbox>
  198. </el-form-item>
  199. <el-form-item :label="$t('计划培训时间')" >
  200. <el-date-picker clearable size="small" style="width: 200px"
  201. v-model="form.planTrainingdate"
  202. type="month"
  203. value-format="yyyy-MM"
  204. v-if="form.notPlan === true"
  205. :placeholder="$t('请选择') + $t('计划培训时间')">
  206. </el-date-picker>
  207. <el-input v-model="form.notTrainingdate" :placeholder="$t('请输入') + $t('计划培训时间')" v-if="form.notPlan === false" />
  208. </el-form-item>
  209. <el-form-item :label="$t('授课人')" prop="lecturer">
  210. <el-select v-model="lecturers" filterable multiple :placeholder="$t('请选择') +$t('授课人')">
  211. <el-option
  212. v-for="dict in lecturerOptions"
  213. :key="dict.staffid"
  214. :label="dict.name"
  215. :value="dict.staffid">
  216. <span style="float: left">{{ dict.name }}</span>
  217. <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.staffid }}</span>
  218. </el-option>
  219. </el-select>
  220. </el-form-item>
  221. <el-form-item :label="$t('课时')" prop="hour">
  222. <el-input v-model="form.hour" :placeholder="$t('请输入') + $t('课时')" />
  223. </el-form-item>
  224. <el-form-item :label="$t('归属部门')" prop="deptId">
  225. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" :placeholder="$t('请选择') + $t('归属部门')" />
  226. </el-form-item>
  227. </el-form>
  228. <div slot="footer" class="dialog-footer">
  229. <el-button type="primary" @click="submitForm" :disabled="submitDisabled">{{ $t('确 定') }}</el-button>
  230. <el-button @click="cancel">{{ $t('取 消') }}</el-button>
  231. </div>
  232. </el-dialog>
  233. <!-- 用户导入对话框 -->
  234. <el-dialog v-dialogDrag :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  235. <el-upload
  236. ref="upload"
  237. :limit="1"
  238. accept=".xlsx, .xls"
  239. :headers="upload.headers"
  240. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  241. :disabled="upload.isUploading"
  242. :on-progress="handleFileUploadProgress"
  243. :on-success="handleFileSuccess"
  244. :auto-upload="false"
  245. drag
  246. >
  247. <i class="el-icon-upload"></i>
  248. <div class="el-upload__text">
  249. {{ $t('将文件拖到此处,或') }}
  250. <em>{{ $t('点击上传') }}</em>
  251. </div>
  252. <div class="el-upload__tip" slot="tip">
  253. <el-checkbox v-model="upload.updateSupport" />{{ $t('是否更新已经存在的用户数据') }}
  254. <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
  255. </div>
  256. <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}</div>
  257. </el-upload>
  258. <div slot="footer" class="dialog-footer">
  259. <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>
  260. <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
  261. </div>
  262. </el-dialog>
  263. </div>
  264. </template>
  265. <script>
  266. import { listRegular, getRegular, delRegular, addRegular, updateRegular, exportRegular, importTemplate} from "@/api/training/regular";
  267. import { listStaffmgr, listAllStaffmgr } from "@/api/plant/staffmgr";
  268. import { treeselect } from "@/api/system/dept";
  269. import { getToken } from "@/utils/auth";
  270. import Treeselect from "@riophae/vue-treeselect";
  271. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  272. export default {
  273. name: "Regular",
  274. components: { Treeselect },
  275. data() {
  276. return {
  277. // 遮罩层
  278. loading: true,
  279. // 选中数组
  280. ids: [],
  281. // 非单个禁用
  282. single: true,
  283. // 非多个禁用
  284. multiple: true,
  285. // 显示搜索条件
  286. showSearch: false,
  287. // 总条数
  288. total: 0,
  289. // 装置培训计划表格数据
  290. regularList: [],
  291. // 弹出层标题
  292. title: "",
  293. // 部门树选项
  294. deptOptions: undefined,
  295. clientHeight:300,
  296. // 是否显示弹出层
  297. open: false,
  298. // 台账显示岗位字典
  299. actualpostIdOptions: [],
  300. // 需参培岗位字典
  301. actualpostOptions: [],
  302. // 授课人字典
  303. lecturerOptions: [],
  304. // 指定岗位字典
  305. designatedPositionOptions: [],
  306. // 指定部门字典
  307. otherPositionOptions: [],
  308. //培训岗位多选
  309. actualpostIds: [],
  310. //指定人员岗位多选
  311. designatedPositions: [],
  312. //其他部门多选
  313. otherPositions: [],
  314. //指定人员id多选
  315. designatedStaffs: [],
  316. //授课人多选
  317. lecturers: [],
  318. //是否存在岗位多选
  319. haveDesignated: false,
  320. //人员表联查
  321. stffmgrOptions: undefined,
  322. //人员表查询参数
  323. staffmgrQueryParams: {
  324. actualposts: null
  325. },
  326. //确认按钮是否可点
  327. submitDisabled: false,
  328. // 用户导入参数
  329. upload: {
  330. // 是否显示弹出层(用户导入)
  331. open: false,
  332. // 弹出层标题(用户导入)
  333. title: "",
  334. // 是否禁用上传
  335. isUploading: false,
  336. // 是否更新已经存在的用户数据
  337. updateSupport: 0,
  338. // 设置上传的请求头部
  339. headers: { Authorization: "Bearer " + getToken() },
  340. // 上传的地址
  341. url: process.env.VUE_APP_BASE_API + "/training/regular/importData"
  342. },
  343. // 查询参数
  344. queryParams: {
  345. pageNum: 1,
  346. pageSize: 20,
  347. year: this.getNowTime()
  348. },
  349. // 表单参数
  350. form: {},
  351. // 表单校验
  352. rules: {
  353. year: [
  354. { required: true, message: this.$t('年份') + this.$t('不能为空'), trigger: "blur" }
  355. ],
  356. courseCode: [
  357. { required: true, message: this.$t('课程代码') + this.$t('不能为空'), trigger: "blur" }
  358. ],
  359. item: [
  360. { required: true, message: this.$t('课程名称') + this.$t('不能为空'), trigger: "blur" }
  361. ],
  362. deptId: [
  363. { required: true, message: this.$t('部门编号')+ this.$t('不能为空'), trigger: "blur" }
  364. ],
  365. }
  366. };
  367. },
  368. watch: {
  369. // 根据名称筛选部门树
  370. deptName(val) {
  371. this.$refs.tree.filter(val);
  372. }
  373. },
  374. created() {
  375. //设置表格高度对应屏幕高度
  376. this.$nextTick(() => {
  377. this.clientHeight = document.body.clientHeight -250
  378. })
  379. this.getDicts("ACTUALPOST").then(response => {
  380. this.actualpostIdOptions = response.data;
  381. });
  382. this.getDicts("ACTUALPOST").then(response => {
  383. this.actualpostOptions = response.data;
  384. });
  385. this.getDicts("ACTUALPOST").then(response => {
  386. this.designatedPositionOptions = response.data;
  387. });
  388. let _this = this
  389. this.getDicts("ACTUALPOST").then(response => {
  390. response.data.forEach(function (positionValue, positionkey, arr) {
  391. if (positionValue.dictValue === "28" || positionValue.dictValue === "30" || positionValue.dictValue === "32") {
  392. _this.otherPositionOptions.push(positionValue)
  393. }
  394. })
  395. this.getStaffmar();
  396. this.getLecturer();
  397. this.getTreeselect();
  398. });
  399. },
  400. methods: {
  401. /** 查询装置培训计划列表 */
  402. getList() {
  403. this.loading = true;
  404. let _this = this
  405. listRegular(this.queryParams).then(response => {
  406. this.regularList = response.rows;
  407. this.regularList.forEach(function (value,key,arr) {
  408. let stffmgrName = "";
  409. if (value.lecturer != null) {
  410. let staffId = value.lecturer.split(",");
  411. staffId.forEach(function (id, index) {
  412. _this.stffmgrOptions.forEach(function (item) {
  413. if (item.staffid === id) {
  414. if (index === 0) {
  415. stffmgrName = item.name
  416. }else {
  417. stffmgrName = stffmgrName + "," + item.name
  418. }
  419. }
  420. });
  421. });
  422. }
  423. _this.regularList[key].lecturerName = stffmgrName
  424. });
  425. this.total = response.total;
  426. this.loading = false;
  427. this.$nextTick(() => {
  428. this.$refs.regularTable.doLayout(); // 解决表格错位
  429. });
  430. });
  431. },
  432. /** 获取当前年份 */
  433. getNowTime() {
  434. var now = new Date();
  435. var year = now.getFullYear(); //得到年份
  436. var defaultDate = `${year}`;
  437. defaultDate = `${year}`
  438. return defaultDate;
  439. },
  440. /** 查询部门下拉树结构 */
  441. getTreeselect() {
  442. treeselect().then(response => {
  443. this.deptOptions = response.data;
  444. });
  445. },
  446. //获取人员表
  447. getStaffmar() {
  448. listStaffmgr(this.staffmgrQueryParams).then(response => {
  449. this.stffmgrOptions = response.rows;
  450. this.$nextTick(() => {
  451. this.getList();
  452. })
  453. });
  454. },
  455. getLecturer(year) {
  456. this.staffmgrQueryParams.leftYear = year
  457. listAllStaffmgr(this.staffmgrQueryParams).then(response => {
  458. this.lecturerOptions = response.rows;
  459. });
  460. },
  461. //根据分数显示颜色提示
  462. tableCellClassName({ row, column, rowIndex, columnIndex }) {
  463. var postNum = this.actualpostIdOptions.length;
  464. for (var i = 0; i < postNum; i++) {
  465. if (columnIndex == 7 + i){
  466. return this.changeColor(row.actualpost[i])
  467. }
  468. }
  469. },
  470. changeColor (value) {
  471. if (value === "M") {
  472. return 'cellChoose'
  473. }else if (value === "|") {
  474. return 'cellDesignated'
  475. }else if (value === "(M)") {
  476. return 'cellInvolvedMoc'
  477. }
  478. },
  479. //需培训岗位变动
  480. changeActualpost() {
  481. let _this = this
  482. this.getDicts("ACTUALPOST").then(response => {
  483. this.designatedPositionOptions = response.data;
  484. this.actualpostIds.forEach(function (value, key, arr) {
  485. _this.designatedPositionOptions.forEach(function (positionValue, positionkey, arr) {
  486. if (positionValue.dictValue === value) {
  487. _this.designatedPositionOptions.splice(positionkey ,1)
  488. }
  489. })
  490. })
  491. });
  492. },
  493. //指定人员训岗位变动
  494. changeDesignated() {
  495. if (this.designatedPositions.length > 0) {
  496. var designatedId = null;
  497. this.designatedPositions.forEach(function (value,key,arr) {
  498. if (key != 0) {
  499. designatedId = designatedId + "," + value;
  500. }else if (key == 0) {
  501. designatedId = value;
  502. }
  503. })
  504. this.staffmgrQueryParams.actualposts = designatedId;
  505. this.staffmgrQueryParams.leftYear = this.form.year
  506. listAllStaffmgr(this.staffmgrQueryParams).then(response => {
  507. this.stffmgrOptions = response.rows;
  508. });
  509. let _this = this
  510. this.getDicts("ACTUALPOST").then(response => {
  511. this.actualpostOptions = response.data;
  512. this.designatedPositions.forEach(function (value, key, arr) {
  513. _this.actualpostOptions.forEach(function (positionValue, positionkey, arr) {
  514. if (positionValue.dictValue === value) {
  515. _this.actualpostOptions.splice(positionkey ,1)
  516. }
  517. })
  518. })
  519. });
  520. }else {
  521. this.designatedStaffs = [];
  522. }
  523. },
  524. //是否涉及其他部门变动
  525. changeInvolved() {
  526. if (this.form.involvedMoc === true) {
  527. this.otherPositions = ['28','30','32']
  528. }else {
  529. this.otherPositions = []
  530. }
  531. },
  532. // 取消按钮
  533. cancel() {
  534. this.open = false;
  535. this.reset();
  536. },
  537. // 表单重置
  538. reset() {
  539. this.form = {
  540. id: null,
  541. courseCode: null,
  542. item: null,
  543. actualpostId: null,
  544. remarks: null,
  545. delFlag: null,
  546. createrCode: null,
  547. createdate: null,
  548. updaterCode: null,
  549. updatedate: null,
  550. deptId: null,
  551. planTrainingdate: null,
  552. actualCompletedate: null,
  553. lecturer: null,
  554. hour: null,
  555. year: null,
  556. designatedPosition: null,
  557. designatedStaff: null,
  558. involvedMoc: null,
  559. designatedOther: null,
  560. notPlan: null,
  561. notTrainingdate: null
  562. };
  563. this.resetForm("form");
  564. },
  565. /** 搜索按钮操作 */
  566. handleQuery() {
  567. this.queryParams.pageNum = 1;
  568. this.getList();
  569. },
  570. /** 重置按钮操作 */
  571. resetQuery() {
  572. this.resetForm("queryForm");
  573. this.handleQuery();
  574. },
  575. // 多选框选中数据
  576. handleSelectionChange(selection) {
  577. this.ids = selection.map(item => item.id)
  578. this.single = selection.length!==1
  579. this.multiple = !selection.length
  580. },
  581. /** 新增按钮操作 */
  582. handleAdd() {
  583. this.reset();
  584. this.open = true;
  585. this.submitDisabled = false;
  586. this.form.involvedMoc = false
  587. this.form.notPlan = true
  588. this.actualpostIds = [];
  589. this.lecturers = [];
  590. this.haveDesignated = false;
  591. this.designatedPositions = [];
  592. this.otherPositions = [];
  593. this.getDicts("ACTUALPOST").then(response => {
  594. this.actualpostOptions = response.data;
  595. });
  596. this.getDicts("ACTUALPOST").then(response => {
  597. this.designatedPositionOptions = response.data;
  598. });
  599. this.title = this.$t('添加') + this.$t('装置') +this.$t('空格') + this.$t('培训计划');
  600. },
  601. /** 修改按钮操作 */
  602. handleUpdate(row) {
  603. this.reset();
  604. let _this = this
  605. this.submitDisabled = false;
  606. const id = row.id || this.ids
  607. getRegular(id).then(response => {
  608. this.form = response.data;
  609. if (this.form.actualpostId != null) {
  610. this.actualpostIds = this.form.actualpostId.split(',');
  611. this.getDicts("ACTUALPOST").then(response => {
  612. this.designatedPositionOptions = response.data;
  613. this.actualpostIds.forEach(function (value, key, arr) {
  614. _this.designatedPositionOptions.forEach(function (positionValue, positionkey, arr) {
  615. if (positionValue.dictValue === value) {
  616. _this.designatedPositionOptions.splice(positionkey ,1)
  617. }
  618. })
  619. })
  620. });
  621. }else {
  622. this.getDicts("ACTUALPOST").then(response => {
  623. this.designatedPositionOptions = response.data;
  624. })
  625. this.actualpostIds = [];
  626. }
  627. if (this.form.designatedPosition != null) {
  628. this.designatedPositions = this.form.designatedPosition.split(',');
  629. this.getDicts("ACTUALPOST").then(response => {
  630. this.actualpostOptions = response.data;
  631. this.designatedPositions.forEach(function (value, key, arr) {
  632. _this.actualpostOptions.forEach(function (positionValue, positionkey, arr) {
  633. if (positionValue.dictValue === value) {
  634. _this.actualpostOptions.splice(positionkey ,1)
  635. }
  636. })
  637. })
  638. });
  639. this.haveDesignated = true;
  640. var designatedId = null;
  641. this.designatedPositions.forEach(function (value,key,arr) {
  642. if (key != 0) {
  643. designatedId = designatedId + "," + value;
  644. }else if (key == 0) {
  645. designatedId = value;
  646. }
  647. })
  648. this.staffmgrQueryParams.actualposts = designatedId;
  649. this.staffmgrQueryParams.leftYear = this.form.year
  650. this.$nextTick(() => {
  651. listStaffmgr(this.staffmgrQueryParams).then(response => {
  652. this.stffmgrOptions = response.rows;
  653. });
  654. })
  655. }else {
  656. this.haveDesignated = false;
  657. this.designatedPositions = [];
  658. this.getDicts("ACTUALPOST").then(response => {
  659. this.actualpostOptions = response.data;
  660. })
  661. }
  662. if (this.form.designatedStaff != null) {
  663. this.designatedStaffs = this.form.designatedStaff.split(',');
  664. }else {
  665. this.designatedStaffs = [];
  666. }
  667. if (this.form.lecturer != null) {
  668. this.lecturers = this.form.lecturer.split(',');
  669. }else {
  670. this.lecturers =[];
  671. }
  672. if (response.data.involvedMoc === 'true') {
  673. this.form.involvedMoc = true
  674. }else {
  675. this.form.involvedMoc = false
  676. }
  677. //指定其他部门下拉框内容
  678. if (this.form.designatedOther != null) {
  679. this.otherPositions = this.form.designatedOther.split(',');
  680. }else {
  681. this.otherPositions = [];
  682. }
  683. if (response.data.notPlan === 'true') {
  684. this.form.notPlan = true
  685. }else {
  686. this.form.notPlan = false
  687. }
  688. this.open = true;
  689. this.title = this.$t('修改') + this.$t('装置') +this.$t('空格') + this.$t('培训计划');
  690. });
  691. },
  692. /** 提交按钮 */
  693. submitForm() {
  694. this.$refs["form"].validate(valid => {
  695. this.submitDisabled = true;
  696. if (valid) {
  697. var id = null;
  698. this.actualpostIds.forEach(function (value,key,arr) {
  699. if (key != 0) {
  700. id = id + "," + value;
  701. }else if (key == 0) {
  702. id = value;
  703. }
  704. })
  705. this.form.actualpostId = id;
  706. var designatedId = null;
  707. this.designatedPositions.forEach(function (value,key,arr) {
  708. if (key != 0) {
  709. designatedId = designatedId + "," + value;
  710. }else if (key == 0) {
  711. designatedId = value;
  712. }
  713. })
  714. // 王子文 2022年4月18日 13点31分 修改
  715. // 如果 复选框被选中 将指定人信息存入数据传输对象
  716. if (this.haveDesignated === true) {
  717. this.form.designatedPosition = designatedId;
  718. } else {
  719. this.form.designatedPosition = null;
  720. }
  721. // this.form.designatedPosition = designatedId;
  722. var designatedOther = null;
  723. this.otherPositions.forEach(function (value,key,arr) {
  724. if (key != 0) {
  725. designatedOther = designatedOther + "," + value;
  726. }else if (key == 0) {
  727. designatedOther = value;
  728. }
  729. })
  730. this.form.designatedOther = designatedOther;
  731. var staffId = null;
  732. this.designatedStaffs.forEach(function (value,key,arr) {
  733. if (key != 0) {
  734. staffId = staffId + "," + value;
  735. }else if (key == 0) {
  736. staffId = value;
  737. }
  738. })
  739. this.form.designatedStaff = staffId;
  740. var lecturerId = null;
  741. this.lecturers.forEach(function (value,key,arr) {
  742. if (key != 0) {
  743. lecturerId = lecturerId + "," + value;
  744. }else if (key == 0) {
  745. lecturerId = value;
  746. }
  747. })
  748. this.form.lecturer = lecturerId;
  749. if (this.form.id != null) {
  750. updateRegular(this.form).then(response => {
  751. this.msgSuccess(this.$t('修改成功'));
  752. this.open = false;
  753. this.submitDisabled = false;
  754. this.getList();
  755. });
  756. } else {
  757. addRegular(this.form).then(response => {
  758. this.msgSuccess(this.$t('新增成功'));
  759. this.open = false;
  760. this.submitDisabled = false;
  761. this.getList();
  762. });
  763. }
  764. }
  765. });
  766. },
  767. /** 删除按钮操作 */
  768. handleDelete(row) {
  769. const ids = row.id || this.ids;
  770. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  771. confirmButtonText: this.$t('确定'),
  772. cancelButtonText: this.$t('取消'),
  773. type: "warning"
  774. }).then(function() {
  775. return delRegular(ids);
  776. }).then(() => {
  777. this.getList();
  778. this.msgSuccess(this.$t('删除成功'));
  779. })
  780. },
  781. /** 导出按钮操作 */
  782. handleExport() {
  783. const queryParams = this.queryParams;
  784. this.$confirm(this.$t('是否确认导出所有装置培训计划数据项?'), this.$t('警告'), {
  785. confirmButtonText: this.$t('确定'),
  786. cancelButtonText: this.$t('取消'),
  787. type: "warning"
  788. }).then(function() {
  789. return exportRegular(queryParams);
  790. }).then(response => {
  791. this.download(response.msg);
  792. })
  793. },
  794. /** 导入按钮操作 */
  795. handleImport() {
  796. this.upload.title = this.$t('用户导入');
  797. this.upload.open = true;
  798. },
  799. /** 下载模板操作 */
  800. importTemplate() {
  801. importTemplate().then(response => {
  802. this.download(response.msg);
  803. });
  804. },
  805. // 文件上传中处理
  806. handleFileUploadProgress(event, file, fileList) {
  807. this.upload.isUploading = true;
  808. },
  809. // 文件上传成功处理
  810. handleFileSuccess(response, file, fileList) {
  811. this.upload.open = false;
  812. this.upload.isUploading = false;
  813. this.$refs.upload.clearFiles();
  814. this.$alert(response.msg, this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  815. this.getList();
  816. },
  817. // 提交上传文件
  818. submitFileForm() {
  819. this.$refs.upload.submit();
  820. }
  821. }
  822. };
  823. </script>
  824. <style scoped>
  825. .colorMark {
  826. color: #6f6f6f;
  827. text-align: right;
  828. font-weight:bold;
  829. font-size: 13px;
  830. padding-bottom: 5px;
  831. }
  832. .rectangleLightgreen {
  833. width: 40px !important;
  834. height: 20px !important;
  835. }
  836. .rectangleFlesh {
  837. width: 40px !important;
  838. height: 20px !important;
  839. }
  840. .rectangleYellow {
  841. width: 40px !important;
  842. height: 20px !important;
  843. }
  844. </style>