综合办公系统
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

scForm.vue 9.5KB

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