post-skill.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div class="mainContentBox">
  3. <!--{{dataDetail}}-->
  4. <!--{{dicts}}-->
  5. <avue-crud
  6. ref="crudRef"
  7. v-model:search="search"
  8. v-model="form"
  9. :data="data"
  10. :option="option"
  11. @row-update="updateRow"
  12. @row-del="deleteRow"
  13. @search-change="searchChange"
  14. @search-reset="resetChange"
  15. @selection-change="selectionChange"
  16. >
  17. <template #menu-left="{ size }">
  18. <el-button
  19. type="primary"
  20. icon="el-icon-plus"
  21. circle
  22. @click="addSkill"
  23. ></el-button
  24. ></template>
  25. <template #footer>
  26. <div class="detail-footer">
  27. <el-button type="primary" @click="addList"> 保存 </el-button>
  28. <el-button @click="cancel">取消</el-button>
  29. </div>
  30. </template>
  31. </avue-crud>
  32. </div>
  33. </template>
  34. <script setup lang="ts">
  35. import { ref, getCurrentInstance } from "vue";
  36. import { useCrud } from "@/hooks/userCrud";
  37. import ButtonPermKeys from "@/common/configs/buttonPermission";
  38. import { useCommonStoreHook, useDictionaryStoreHook } from "@/store/index";
  39. import {addPostSkill} from "../../../../api/system/skill";
  40. const { isShowTable, tableType } = toRefs(useCommonStoreHook());
  41. // 数据字典相关
  42. const { dicts } = useDictionaryStoreHook();
  43. const router = useRouter();
  44. const route = useRoute();
  45. const dataDetail=ref({});
  46. const test = () => {
  47. isShowTable.value = true;
  48. tableType.value = tableType.value == 1 ? 2 : 1;
  49. };
  50. const formData=ref({});
  51. const dataBomLists=()=>{
  52. search.value.materialCode=route.value.materialCode;
  53. dataNoPageList();
  54. }
  55. const dialog=ref(null);
  56. const addList=()=>{
  57. for(var i=0;i<data.value.length;i++){
  58. if(data.value[i].skillDictValue==="0"||data.value[i].skillDictValue ===null){
  59. ElMessage({
  60. message:"技能选项存在空值",
  61. type: "error",
  62. });
  63. return;
  64. }
  65. }
  66. if(data.value.length===0){
  67. ElMessage({
  68. message: "没有添加记录!",
  69. type: "error",
  70. });
  71. return;
  72. }
  73. addPostSkill(data.value).then(
  74. (data: any)=>{
  75. if(data.code==="200") {
  76. ElMessage({
  77. message: data.msg,
  78. type: "success",
  79. });
  80. }
  81. else {
  82. ElMessage({
  83. message: data.msg,
  84. type: "error",
  85. });
  86. }
  87. props.dialog.visible=false;
  88. }
  89. );
  90. }
  91. // 传入一个url,后面不带/
  92. const { form, data, option, search, page, toDeleteIds, Methords, Utils } =
  93. useCrud({
  94. src: "/api/v1/sys/postSkill",
  95. });
  96. const { dataNoPageList,createRow, updateRow, deleteRow, searchChange, resetChange } =
  97. Methords; //增删改查
  98. const { selectionChange, multipleDelete } = Methords; //选中和批量删除事件
  99. const { checkBtnPerm, downloadTemplate, exportData } = Utils; //按钮权限等工具
  100. // checkBtnPerm(ButtonPermKeys.PLAN.BTNS.order_add) :permission="permission"
  101. // const permission = reactive({
  102. // delBtn: checkPerm(buttonPermission.PLAN.BTNS.order_del),
  103. // addBtn: checkPerm(buttonPermission.PLAN.BTNS.order_add),
  104. // editBtn: checkPerm(buttonPermission.PLAN.BTNS.order_edit),
  105. // menu: true,
  106. // });
  107. const crudRef = ref(null); //crudRef.value 获取avue-crud对象
  108. const props = defineProps({
  109. postId: {
  110. type: Number,
  111. default: () => {
  112. return 0;
  113. }
  114. },
  115. dialog:{
  116. type:Object,
  117. default:()=>{
  118. return {};
  119. }
  120. }
  121. })
  122. onMounted(() => {
  123. // console.log("crudRef", crudRef)
  124. search.value.postId=props.postId;
  125. dataNoPageList();
  126. });
  127. const cancel=()=>{
  128. props.dialog.visible=false;
  129. }
  130. /**
  131. * 上传excel相关
  132. */
  133. const uploadRef = ref(null);
  134. const uploadFinished = () => {
  135. // 上传完成后的刷新操作
  136. dataNoPageList();
  137. };
  138. const importExcelData = () => {
  139. if (uploadRef.value) {
  140. uploadRef.value.show("/api/v1/plan/order/import");
  141. }
  142. };
  143. // 设置表格列或者其他自定义的option
  144. option.value = Object.assign(option.value, {
  145. selection: false,
  146. addBtn: false,
  147. viewBtn: false,
  148. editBtn:false,
  149. saveBtn:false,
  150. cellBtn: true,
  151. column: [{
  152. label: "技能",
  153. prop: "skillDictValue",
  154. align: 'center',
  155. headerAlign: 'center',
  156. cell: true,
  157. span:24,
  158. type: 'select',
  159. dicData:dicts.skill_type,
  160. props: {
  161. label: "dictLabel", // 下拉菜单显示的字段
  162. value: "dictValue" // 下拉菜单值的字
  163. },
  164. },],
  165. });
  166. const routeBack =()=>{
  167. router.back();
  168. }
  169. const addSkill = () => {
  170. const bom=ref({
  171. postId:props.postId,
  172. $cellEdit:true,
  173. });
  174. data.value.push(bom.value);
  175. };
  176. </script>
  177. <style type="text/css">
  178. .title-detail{
  179. width: 30%;
  180. height: 50px;
  181. line-height: 50px;
  182. margin: 25px 20px 25px 0;
  183. float: left;
  184. }
  185. .detail{
  186. margin: 0 auto;
  187. width: 100%;
  188. }
  189. .avue-crud{
  190. float: left;
  191. }
  192. .detail-footer{
  193. float: right;
  194. margin-top:15px;
  195. }
  196. .el-select__selection{
  197. width: 400px;
  198. }
  199. </style>