trainingNon.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <el-dialog :close-on-click-modal="false" v-dialogDrag
  3. :title="$t('未参会人员名单')"
  4. :visible.sync="visible"
  5. @close="closeDialog">
  6. <el-form :inline="true" :model="queryParams" @keyup.enter.native="getDataList()">
  7. <el-form-item>
  8. <el-button v-hasPermi="['training:training:trainingNon']" type="primary" @click="add()">{{ $t('新增') }}</el-button>
  9. </el-form-item>
  10. </el-form>
  11. <el-table :data="trainingNonList" border>
  12. <el-table-column :label="$t('未参会人员姓名')" align="center" header-align="center" prop="staffId" :show-overflow-tooltip="true">
  13. <template slot-scope="scope">
  14. <el-select v-model="scope.row.staffId" v-if="scope.row.isEdit" filterable :placeholder="$t('请选择') + $t('未参会人员名单')">
  15. <el-option
  16. v-for="dict in stffmgrOptions"
  17. :key="dict.staffid"
  18. :label="dict.name"
  19. :value="dict.staffid">
  20. <span style="float: left">{{ dict.name }}</span>
  21. <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.staffid }}</span>
  22. </el-option>
  23. </el-select>
  24. <span v-else>{{scope.row.name}}</span>
  25. </template>
  26. </el-table-column>
  27. <el-table-column :label="$t('培训日期')" align="center" header-align="center" prop="trainingDate">
  28. <template slot-scope="scope">
  29. <el-date-picker
  30. v-if="scope.row.isEdit"
  31. v-model="scope.row.trainingDate"
  32. type="date"
  33. value-format="yyyy-MM-dd"
  34. :placeholder="$t('日期')">
  35. </el-date-picker>
  36. <span v-else>{{ parseTime(scope.row.trainingDate, '{y}-{m}-{d}') }}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column :label="$t('补培讲师')" align="center" header-align="center" prop="trainingStaff" :show-overflow-tooltip="true">
  40. <template slot-scope="scope">
  41. <el-select v-model="scope.row.trainingStaff" v-if="scope.row.isEdit" filterable :placeholder="$t('请选择') + $t('补培讲师')">
  42. <el-option
  43. v-for="dict in trainingstaffOptions"
  44. :key="dict.staffid"
  45. :label="dict.name"
  46. :value="dict.staffid">
  47. <span style="float: left">{{ dict.name }}</span>
  48. <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.staffid }}</span>
  49. </el-option>
  50. </el-select>
  51. <span v-else>{{scope.row.staffName}}</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column :label="$t('备注')" align="center" header-align="center" prop="remarks" :show-overflow-tooltip="true">
  55. <template slot-scope="scope">
  56. <el-input v-if="scope.row.isEdit" v-model="scope.row.remarks"></el-input>
  57. <span v-else>{{scope.row.remarks}}</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column :label="$t('操作')" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  61. <template slot-scope="scope">
  62. <el-button v-hasPermi="['training:training:trainingNon']" type="text" size="small" v-if="scope.row.isEdit" @click="save(scope.row)">{{ $t('保存') }}</el-button>
  63. <el-button type="text" size="small" v-if="scope.row.isEdit" @click="cancel(scope.row, scope.$index)">{{ $t('取消') }}</el-button>
  64. <el-button v-hasPermi="['training:training:trainingNon']" v-if="!scope.row.isEdit" @click="edit(scope.row)" type="text" size="mini">{{ $t('编辑') }}</el-button>
  65. <el-button v-hasPermi="['training:training:trainingNon']" v-if="!scope.row.isEdit" type="text" size="small" @click="deleteHandle(scope.row)">{{ $t('删除') }}</el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. </el-dialog>
  70. </template>
  71. <script>
  72. import { listTrainingNon, getTrainingNon, delTrainingNon, addTrainingNon, updateTrainingNon, exportTrainingNon, importTemplate} from "@/api/training/trainingNon";
  73. import { listStaffmgr,listAllStaffmgr, selectByStaffId } from "@/api/plant/staffmgr";
  74. export default {
  75. name: "TrainingNon",
  76. props: {
  77. // 接受父级组件的显示标记,用于被watch
  78. showFlag: {
  79. type: Boolean
  80. }
  81. },
  82. data() {
  83. return {
  84. visible: false,
  85. // 查询参数
  86. queryParams: {
  87. pageNum: 1,
  88. pageSize: 20,
  89. trainingId: '',
  90. isNew: 0
  91. },
  92. //人员表查询参数
  93. staffmgrQueryParams: {
  94. staffid: null,
  95. unit: null,
  96. actualposts: null,
  97. leftYear: null
  98. },
  99. trainingStaffQueryParams: {
  100. leftYear: null
  101. },
  102. // 培训计划未参加人员表格数据
  103. trainingNonList: [],
  104. //人员表联查
  105. stffmgrOptions: undefined,
  106. trainingstaffOptions: undefined,
  107. //指定人员名单
  108. designatedStaffs: [],
  109. // 总条数
  110. total: 0,
  111. // 表单参数
  112. form: {},
  113. }
  114. },
  115. watch: {
  116. // 观察父级组件的showFlag,并将showFlag的最新值设置给dialogVisible
  117. showFlag (newVal, oldVal) {
  118. this.visible = newVal
  119. }
  120. },
  121. methods: {
  122. init (row) {
  123. this.queryParams.trainingId = row.id || 0
  124. this.staffmgrQueryParams.leftYear = row.year
  125. this.trainingStaffQueryParams.leftYear = row.year
  126. this.staffmgrQueryParams.units = row.unitid
  127. this.staffmgrQueryParams.actualposts = row.positionid
  128. if (row.designatedStaff != null) {
  129. this.designatedStaffs = row.designatedStaff.split(',')
  130. }else {
  131. this.designatedStaffs = []
  132. }
  133. this.getStaffmar()
  134. this.visible = true
  135. },
  136. //获取人员表
  137. getStaffmar() {
  138. listAllStaffmgr(this.staffmgrQueryParams).then(response => {
  139. this.stffmgrOptions = response.rows;
  140. if (this.designatedStaffs.length > 0) {
  141. selectByStaffId(this.designatedStaffs).then(response => {
  142. this.stffmgrOptions = this.stffmgrOptions.concat(response.data)
  143. })
  144. }
  145. });
  146. listAllStaffmgr(this.trainingStaffQueryParams).then(response => {
  147. this.trainingstaffOptions = response.rows;
  148. });
  149. this.$nextTick(() => {
  150. this.getList();
  151. })
  152. },
  153. /** 查询培训计划未参加人员列表 */
  154. getList() {
  155. this.loading = true;
  156. listTrainingNon(this.queryParams).then(response => {
  157. this.total = response.total;
  158. response.rows.forEach(element => {
  159. element["isEdit"] = false
  160. });
  161. response.rows.forEach(element => {
  162. element["isAdd"] = false
  163. });
  164. this.trainingNonList = response.rows;
  165. this.loading = false;
  166. });
  167. },
  168. /**
  169. * 关闭弹出框事件,触发父级组件的getList方法
  170. */
  171. closeDialog () {
  172. this.$emit('closeChildDialog')
  173. },
  174. // 取消
  175. cancel(row, index) {
  176. // 如果是新增的数据
  177. if (row.isAdd) {
  178. this.trainingNonList.splice(index, 1)
  179. } else {
  180. // 不是新增的数据 还原数据
  181. for (const i in row.oldRow) {
  182. row[i] = row.oldRow[i]
  183. }
  184. row.isEdit = false
  185. }
  186. },
  187. edit(row) {
  188. // 备份原始数据
  189. row['oldRow'] = JSON.parse(JSON.stringify(row));
  190. this.$nextTick(() => {
  191. row.isEdit = true;
  192. })
  193. },
  194. // 表单重置
  195. reset() {
  196. this.form = {
  197. id: null,
  198. delFlag: null,
  199. createrCode: null,
  200. createdate: null,
  201. updaterCode: null,
  202. updatedate: null,
  203. remarks: null,
  204. trainingDate: null,
  205. staffId: null,
  206. trainingId: null,
  207. trainingStaff: null,
  208. isNew: 0
  209. };
  210. this.resetForm("form");
  211. },
  212. add() {
  213. this.trainingNonList.push({
  214. trainingId: this.queryParams.trainingId,
  215. staffId: '',
  216. trainingDate: '',
  217. isNew: 0,
  218. isEdit: true,
  219. isAdd: true
  220. });
  221. },
  222. save(row) {
  223. row.isEdit = false;
  224. var that = this;
  225. that.loading = true;
  226. this.form = row;
  227. this.form.trainingId = this.queryParams.trainingId;
  228. this.form.isNew = 0;
  229. if (row.isAdd == true) {
  230. addTrainingNon(this.form).then(response => {
  231. this.msgSuccess(this.$t('新增成功'));
  232. this.open = false;
  233. this.getList();
  234. });
  235. }else {
  236. updateTrainingNon(this.form).then(response => {
  237. this.msgSuccess(this.$t('修改成功'));
  238. this.open = false;
  239. this.getList();
  240. });
  241. }
  242. },
  243. /** 删除按钮操作 */
  244. deleteHandle(row) {
  245. const ids = row.id || this.ids;
  246. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  247. confirmButtonText: this.$t('确定'),
  248. cancelButtonText: this.$t('取消'),
  249. type: "warning"
  250. }).then(function() {
  251. return delTrainingNon(ids);
  252. }).then(() => {
  253. this.getList();
  254. this.msgSuccess(this.$t('删除成功'));
  255. })
  256. },
  257. }
  258. };
  259. </script>