综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scForm.vue 7.2KB

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