综合办公系统
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

scForm.vue 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <!--
  2. * @Author: ysh
  3. * @Date: 2024-01-19 16:29:01
  4. * @LastEditors: Please set LastEditors
  5. * @LastEditTime: 2024-01-30 10:43:19
  6. -->
  7. <template>
  8. <div>
  9. <el-form ref="scform" :model="form">
  10. <el-form-item label="选择项目:">
  11. <el-select v-model="form.projectId" placeholder="请选择项目">
  12. <el-option v-for="item in projectList" :key="item.value" :label="item.label" :value="item.value">
  13. </el-option>
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item label="工作自述:">
  17. <el-input style="width:900px" type="textarea" :rows="2" placeholder="请输入内容" v-model="form['selfAssess']">
  18. </el-input>
  19. </el-form-item>
  20. <el-form-item label="选择考核项:">
  21. <el-checkbox-group v-model="checkedBtn" @change="assessChangeFn">
  22. <el-checkbox v-for="sc, index in AssessmentContent" :label="sc.label" :key="index">{{ sc.label
  23. }}</el-checkbox>
  24. </el-checkbox-group>
  25. </el-form-item>
  26. <div class="tips" v-if="tipsShow">请至少选择一项考核项</div>
  27. <el-row type="flex" style="flex-wrap:wrap;">
  28. <el-card v-for="item, index in checkedBtn" style="flex:1;margin:10px;min-width: 400px;max-width: 450px;"
  29. :key="index">
  30. <div slot="header" class="clearfix">
  31. <strong>{{ item }}</strong>
  32. <el-button style="float: right; padding: 3px 0" type="text" @click="closeItem(item)">关闭</el-button>
  33. </div>
  34. <el-scrollbar style="height: 500px;">
  35. <div v-for="ass in AssessmentContent" v-if="ass.label == item">
  36. <table border="1" cellspacing="0" align="center" cellpadding="5">
  37. <tr style="background-color:#409EFF;color:#fff;">
  38. <td>等级、比例尺等</td>
  39. <td>工作量</td>
  40. <td>单位</td>
  41. </tr>
  42. <tr v-for="child in ass.children">
  43. <td v-if="!Array.isArray(child.label)">{{ child.label }}</td>
  44. <td v-else>
  45. <el-checkbox-group v-model="form.f07">
  46. <el-checkbox v-for="label, index in child.label" :label="label" :key="'k' + index"></el-checkbox>
  47. </el-checkbox-group>
  48. </td>
  49. <td v-if="Array.isArray(child.label)">
  50. <el-input v-model="form[child.value]" style="width: 100%"></el-input>
  51. </td>
  52. <td v-if="!Array.isArray(child.label)">
  53. <el-input v-model="form[child.value]" style="width: 100%"></el-input>
  54. </td>
  55. <td>{{ child.unit }}</td>
  56. </tr>
  57. <tr>
  58. <td>熟练程度</td>
  59. <td colspan="2">
  60. <el-radio-group v-model="form['familiar' + ass.value.slice(-2)]">
  61. <el-radio :label="0">生疏</el-radio>
  62. <el-radio :label="2">熟练</el-radio>
  63. </el-radio-group>
  64. </td>
  65. </tr>
  66. <tr>
  67. <td>承担角色</td>
  68. <td colspan="2">
  69. <el-checkbox-group v-model="form['role' + ass.value.slice(-2)]">
  70. <el-checkbox v-for="role, index in ass.role" :label="role.slice(-2)" :key="'kk' + index">{{
  71. getRoleLabel(role) }}</el-checkbox>
  72. </el-checkbox-group>
  73. </td>
  74. </tr>
  75. <tr>
  76. <td>备注</td>
  77. <td colspan="2">
  78. <el-input type="textarea" :rows="2" placeholder="请输入内容"
  79. v-model="form['remark' + ass.value.slice(-2)]">
  80. </el-input>
  81. </td>
  82. </tr>
  83. </table>
  84. <div class="tips" v-if="inputTips">工作量只能输入数字</div>
  85. </div>
  86. </el-scrollbar>
  87. </el-card>
  88. </el-row>
  89. <el-form-item label="其他工作:">
  90. <el-input style="width:900px" type="textarea" :rows="2" placeholder="请输入内容" v-model="form['otherWork']">
  91. </el-input>
  92. </el-form-item>
  93. <el-row>
  94. <el-button @click="generateForm" type="primary">生成考核表</el-button>
  95. </el-row>
  96. </el-form>
  97. <el-dialog title="" :visible.sync="taskOpen" width="65%" append-to-body>
  98. <ScTable :tableForm="noNullForm" ref="scTable" @submit="submit"></ScTable>
  99. </el-dialog>
  100. </div>
  101. </template>
  102. <script>
  103. import { SCContent } from '@/assets/datas/SCContent'
  104. import { MessageBox } from 'element-ui'
  105. import ScTable from './scTable.vue';
  106. import { Snowflake } from '@/utils/snowFlake.js'
  107. import { submitAssess } from '@/api/oa/assess/assess.js'
  108. export default {
  109. dicts: ['cmc_skill'],
  110. components: { ScTable },
  111. data() {
  112. return {
  113. checkedBtn: [],
  114. AssessmentContent: SCContent,
  115. projectList: [],
  116. form: {},
  117. noNullForm: {},
  118. taskOpen: false,
  119. tipsShow: false,
  120. inputTips: false
  121. };
  122. },
  123. created() {
  124. this.initForm();
  125. },
  126. watch: {},
  127. mounted() {
  128. },
  129. methods: {
  130. initForm() {
  131. for (let i = 0; i < SCContent.length + 1; i++) {
  132. if (i.toString().length == 1) {
  133. this.$set(this.form, 'role' + '0' + i, []);
  134. }
  135. else {
  136. this.$set(this.form, 'role' + i, []);
  137. }
  138. }
  139. },
  140. // 提交表单
  141. submit(tableForm) {
  142. MessageBox.confirm('确认提交?', '任务提交', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
  143. tableForm.formId = new Snowflake(1n, 1n, 0n).nextId().toString();
  144. tableForm.disabled = true;
  145. console.log(tableForm);
  146. let formData = new FormData();
  147. let form = JSON.stringify(tableForm);
  148. formData.append("form", form);
  149. submitAssess(formData).then(res => {
  150. this.taskOpen = false;
  151. this.$emit('submit', tableForm);
  152. });
  153. }).catch(() => {
  154. });
  155. },
  156. // 生成考核表格
  157. generateForm() {
  158. let flag = 0;
  159. if (this.checkedBtn.length == 0) {
  160. this.tipsShow = true;
  161. return
  162. }
  163. for (let f in this.form) {
  164. if (this.form[f] != "" && this.form[f] != [] && this.form[f] !== undefined) {
  165. this.$set(this.noNullForm, f, this.form[f])
  166. }
  167. if (f.indexOf('familiar') != -1) {
  168. this.$set(this.noNullForm, f, this.form[f])
  169. }
  170. }
  171. for (let btn of this.checkedBtn) {
  172. let ids = this.changeLabelToValue(btn);
  173. if (this.form['familiar' + ids] == undefined || this.form['role' + ids].length == 0) {
  174. this.$message.error('承担角色和熟练程度为必填项,请完善!');
  175. flag = 0
  176. break
  177. } else {
  178. flag = 1
  179. }
  180. }
  181. if (flag) {
  182. this.taskOpen = true;
  183. if (this.$refs.scTable != undefined) {
  184. this.$refs.scTable.formatForm();
  185. }
  186. }
  187. },
  188. closeItem(item) {
  189. let index = this.checkedBtn.indexOf(item);
  190. let number;
  191. if (index !== -1) {
  192. this.checkedBtn.splice(index, 1);
  193. }
  194. for (let i of SCContent) {
  195. if (i.label == item) {
  196. number = i.value;
  197. }
  198. }
  199. for (let fkey in this.form) {
  200. if (fkey.substring(0, 3) == number) {
  201. if (typeof (this.form[fkey]) == 'string') {
  202. this.form[fkey] = "";
  203. }
  204. else if (Array.isArray(this.form[fkey])) {
  205. this.form[fkey] = [];
  206. }
  207. }
  208. this.form['role' + number.substring(1, 3)] = [];
  209. this.form['familiar' + number.substring(1, 3)] = undefined;
  210. this.form['remark' + number.substring(1, 3)] = "";
  211. }
  212. },
  213. assessChangeFn(val) {
  214. if (val.length != 0) {
  215. this.tipsShow = false;
  216. }
  217. },
  218. getRoleLabel(role) {
  219. let len = role.length;
  220. return role.substring(0, len - 2);
  221. },
  222. mustNumber(val, event) {
  223. let regex = /^\d+(\.\d{1,2})?$/;
  224. let newElement = document.createElement("div");
  225. newElement.innerHTML = '工作量必须是数字';
  226. newElement.classList.add('inputTips');
  227. if (regex.test(val) || val == "") {
  228. this.inputTips = false;
  229. } else {
  230. this.inputTips = true;
  231. event.target.parentNode.appendChild(newElement, event.target)
  232. }
  233. },
  234. changeLabelToValue(label) {
  235. for (let s of SCContent) {
  236. if (s.label == label) {
  237. return s.value.slice(-2)
  238. }
  239. }
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .tips {
  246. color: #f00;
  247. font-size: 12px;
  248. line-height: 18px;
  249. }
  250. </style>
  251. <style>
  252. .inputTips {
  253. color: #f00;
  254. font-size: 12px;
  255. line-height: 18px;
  256. display: block;
  257. }
  258. </style>