index.vue 30 KB

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