user-skill.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <div class="mainContentBox">
  3. <avue-form
  4. ref="formRef"
  5. v-model:search="search"
  6. v-model="form"
  7. :data="data"
  8. :option="option2"
  9. v-model:page="page"
  10. @row-save="createRow"
  11. @row-update="updateRow"
  12. @row-del="deleteRow"
  13. @search-change="searchChange"
  14. @size-change="dataList"
  15. @current-change="dataList"
  16. @selection-change="selectionChange"
  17. >
  18. </avue-form>
  19. <avue-crud
  20. ref="crudRef"
  21. v-model="form"
  22. :data="data"
  23. :option="option"
  24. v-model:page="page"
  25. @row-save="createRow"
  26. @row-update="updateRow"
  27. @row-del="deleteRow"
  28. >
  29. <template #skillDictValue="{row,index,type}">
  30. <el-select v-model="skillValue" placeholder="请选择技能" @click="getPostSkills()" @change="skillChange(row)">
  31. <el-option
  32. v-for="item in optionSkill"
  33. :key="item.value"
  34. :label="item.skillDictLabel"
  35. :value="item.skillDictValue"
  36. >
  37. </el-option>
  38. </el-select>
  39. </template>
  40. <template #menu-left="{ size }">
  41. <el-button
  42. type="primary"
  43. icon="el-icon-plus"
  44. circle
  45. @click="addSkill"
  46. ></el-button
  47. ></template>
  48. </avue-crud>
  49. <CommonTable
  50. ref="ctableRef"
  51. tableTitle="员工选择"
  52. tableType="USERS"
  53. @selected-sure="onSelectedFinish"
  54. />
  55. <div class="detail-footer">
  56. <el-button type="primary" @click="onHandle"> 确定 </el-button>
  57. <el-button @click="cancelWindow">取消</el-button>
  58. </div>
  59. </div>
  60. </template>
  61. <script setup>
  62. import { ref, getCurrentInstance } from "vue";
  63. import { useCrud } from "@/hooks/userCrud";
  64. import { useCommonStoreHook, useDictionaryStore } from "@/store";
  65. import dictDataUtil from "@/common/configs/dictDataUtil";
  66. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  67. import {getPostSkill,addEmployeeSkill} from "@/api/system/skill";
  68. // 数据字典相关
  69. const { dicts } = useDictionaryStore();
  70. const test = () => {
  71. isShowTable.value = true;
  72. tableType.value = tableType.value == 1 ? 2 : 1;
  73. };
  74. const data2=ref(null);
  75. // 传入一个url,后面不带/
  76. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  77. useCrud({
  78. src: "/api/v1/sys/skillScore",
  79. });
  80. const { dataList, createRow, updateRow, deleteRow, searchChange, dataNoPageList } =
  81. Methords; //增删改查
  82. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  83. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  84. // checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
  85. // const permission = reactive({
  86. // delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
  87. // addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
  88. // editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
  89. // menu: true,
  90. // });
  91. const option2=ref(null);
  92. const ctableRef = ref(null); //crudRef.value 获取avue-crud对象
  93. const router = useRouter();
  94. onMounted(() => {
  95. // console.log("crudRef", crudRef)
  96. //dataNoPageList();
  97. });
  98. const skillChange=(row)=>{
  99. if(skillValue.value!==undefined&&skillValue.value!==null&&skillValue.value!==""){
  100. data.value[row.$index].skillDictValue=skillValue.value;
  101. }
  102. }
  103. const cancelWindow=()=>{
  104. props.dialog.visible=false;
  105. }
  106. const addSkill = () => {
  107. const bom=ref({
  108. $cellEdit:true,
  109. });
  110. data.value.push(bom.value);
  111. };
  112. const employeeSkill=ref({});
  113. const onHandle=()=>{
  114. console.info(form.value);
  115. if(form.value.userId===null||form.value.userId===undefined||form.value.userId===""){
  116. ElMessage({
  117. message: "未选择打分用户",
  118. type: "error",
  119. });
  120. return false;
  121. }
  122. if(form.value.postId===null||form.value.postId===undefined||form.value.postId===""){
  123. ElMessage({
  124. message: "未选择岗位",
  125. type: "error",
  126. });
  127. return false;
  128. }
  129. console.info("data",data.value);
  130. if(data.value.length===0){
  131. ElMessage({
  132. message: "没有要保存的打分项",
  133. type: "error",
  134. });
  135. return false;
  136. }
  137. if(data.value.length>0){
  138. for(let i=0;i<data.value.length;i++){
  139. if(data.value[i].skillDictValue===undefined||data.value[i].skillDictValue===null||data.value[i].skillDictValue===""){
  140. ElMessage({
  141. message: "第"+(i+1)+"项没有选择技能",
  142. type: "error",
  143. });
  144. return false;
  145. }
  146. if(data.value[i].score===undefined||data.value[i].score===null||data.value[i].score===""){
  147. ElMessage({
  148. message: "第"+(i+1)+"项没有打分",
  149. type: "error",
  150. });
  151. return false;
  152. }
  153. }
  154. }
  155. employeeSkill.value.userId=form.value.userId;
  156. employeeSkill.value.postId=form.value.postId;
  157. employeeSkill.value.skillList=Array.from(data.value);
  158. console.info("11",employeeSkill.value)
  159. addEmployeeSkill(employeeSkill.value).then(
  160. (data)=>{
  161. if(data.code==="200") {
  162. ElMessage({
  163. message: data.msg,
  164. type: "success",
  165. });
  166. props.dialog.visible=false;
  167. }
  168. else {
  169. ElMessage({
  170. message: data.msg,
  171. type: "error",
  172. });
  173. }
  174. }
  175. )
  176. }
  177. const postIdValue=ref(null);
  178. // 设置表格列或者其他自定义的option
  179. option2.value = {
  180. selection: true,
  181. submitBtn:false,
  182. clearAbleBtn:false,
  183. emptyBtn:false,
  184. column: [
  185. { label: "用户id", prop: "userId", width: 130,overHidden: true,search: true ,
  186. filterable: true,
  187. disabled:true,
  188. display:false,
  189. },
  190. { label: "用户名", prop: "userName", width: 140,overHidden: true,search: true ,rules: [{
  191. required: true,
  192. search: true,
  193. message: "请选择员工姓名",
  194. trigger: "blur"
  195. }],
  196. click: ({ value, column }) => {
  197. ctableRef.value.startSelect();
  198. },},
  199. { label: "所属机构", prop: "deptName", width: 130,overHidden: true,search: true ,
  200. filterable: true,
  201. disabled:true,
  202. },
  203. {
  204. label: "员工编号",
  205. prop: "employeeCode",
  206. search: true,
  207. disabled:true,
  208. },
  209. { label: "岗位", prop: "postId",
  210. search: true,
  211. filterable: true,
  212. type: "select",
  213. overHidden: true,
  214. dicUrl:dictDataUtil.post_list_url,
  215. dicMethod:"post",
  216. change:({ value, column })=>{
  217. if(value!==undefined) {
  218. postIdValue.value = value;
  219. skillValue.value=null;
  220. optionSkill.value=null;
  221. }
  222. },
  223. props: { label: "postName", value: "id" },
  224. },
  225. /* { label: "部门", prop: "deptName", overHidden: true,
  226. disabled:true, },*/
  227. ],
  228. };
  229. const props = defineProps({
  230. dialog:{
  231. type:Object,
  232. default:()=>{
  233. return {};
  234. }
  235. }
  236. })
  237. // 设置表格列或者其他自定义的option
  238. option.value = Object.assign(option.value,{
  239. selection: false,
  240. addBtn: false,
  241. viewBtn: false,
  242. editBtn:false,
  243. saveBtn:false,
  244. cellBtn: true,
  245. column: [{
  246. label: "技能",
  247. prop: "skillDictValue",
  248. align: 'center',
  249. headerAlign: 'center',
  250. span:24,
  251. type: 'select',
  252. dicData:dicts.skill_type,
  253. props: { label: "dictLabel", value: "dictValue" },
  254. },
  255. {
  256. label: "分数",
  257. prop: "score",
  258. align: 'center',
  259. headerAlign: 'center',
  260. cell: true,
  261. type:"number",
  262. precision: 2,
  263. max:100,
  264. min:0,
  265. span:24,
  266. },],
  267. });
  268. const onSelectedFinish=(selectedValue)=>{
  269. form.value.userId=selectedValue.id;
  270. form.value.userName=selectedValue.userName;
  271. form.value.deptName=selectedValue.deptName;
  272. form.value.employeeCode=selectedValue.employeeCode;
  273. form.value.institution=selectedValue.institution;
  274. }
  275. const skillValue=ref(null);
  276. const optionSkill=ref([]);
  277. const getPostSkills=()=>{
  278. if(postIdValue.value===undefined||postIdValue.value===null||postIdValue.value===""){
  279. ElMessage({
  280. message: "未选择岗位",
  281. type: "error",
  282. });
  283. return false;
  284. }
  285. getPostSkill(postIdValue.value).then(
  286. (data)=>{
  287. optionSkill.value=Array.from(data.data);
  288. }
  289. )
  290. }
  291. </script>
  292. <style type="text/css">
  293. .title-detail{
  294. width: 30%;
  295. height: 50px;
  296. line-height: 50px;
  297. margin: 25px 20px 25px 0;
  298. float: left;
  299. }
  300. .detail{
  301. margin: 0 auto;
  302. width: 100%;
  303. }
  304. .avue-crud{
  305. float: left;
  306. }
  307. .detail-footer{
  308. float: right;
  309. margin-top:15px;
  310. }
  311. .el-select__selection{
  312. width: 150px;
  313. }
  314. </style>