MedicalAndsocialSecurity.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div style="width: 100%; padding: 0px 15px">
  3. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="formDom">
  4. </byForm>
  5. </div>
  6. </template>
  7. <script setup>
  8. import byForm from "@/components/byForm/index";
  9. import { useRoute } from "vue-router";
  10. const { proxy } = getCurrentInstance();
  11. const route = useRoute();
  12. // 接收父组件的传值
  13. const props = defineProps({
  14. queryData: Object,
  15. });
  16. const selectData = ref([]);
  17. const userList = ref([]);
  18. const deptData = ref([]);
  19. const formData = reactive({
  20. data: {
  21. applyItem: [],
  22. costBearing: "按照法定比例",
  23. deductionMethod: "从工资中扣除",
  24. },
  25. });
  26. const formDom = ref(null);
  27. const judgeStatus = () => {
  28. if (route.query.processType == 20 || route.query.processType == 10) {
  29. return true;
  30. }
  31. if (props.queryData.recordList && props.queryData.recordList.length > 0) {
  32. let data = props.queryData.recordList.filter(
  33. (item) => item.status === 2 && item.nodeType !== 1
  34. );
  35. if (data && data.length > 0) {
  36. return true;
  37. }
  38. }
  39. return false;
  40. };
  41. const formOption = reactive({
  42. inline: true,
  43. labelWidth: 100,
  44. itemWidth: 100,
  45. disabled: false,
  46. });
  47. const formConfig = computed(() => {
  48. return [
  49. {
  50. type: "title",
  51. title: "基本信息",
  52. haveLine: false,
  53. },
  54. {
  55. type: "input",
  56. prop: "code",
  57. label: "流水号",
  58. placeholder: " ",
  59. itemWidth: 50,
  60. disabled: true,
  61. },
  62. {
  63. type: "select",
  64. prop: "createUser",
  65. label: "申请人",
  66. required: true,
  67. filterable: true,
  68. data: userList.value,
  69. itemWidth: 50,
  70. disabled: true,
  71. },
  72. {
  73. type: "date",
  74. prop: "applyTime",
  75. itemType: "date",
  76. label: "申请日期",
  77. itemWidth: 50,
  78. disabled: false,
  79. },
  80. {
  81. type: "treeSelect",
  82. prop: "companyId",
  83. label: "所属公司",
  84. data: proxy.useUserStore().allDict["tree_all_company_data"],
  85. propsTreeLabel: "deptName",
  86. propsTreeValue: "deptId",
  87. itemWidth: 50,
  88. fn: (val) => {},
  89. disabled: true,
  90. },
  91. {
  92. type: "treeSelect",
  93. prop: "deptId",
  94. label: "所属部门",
  95. data: deptData.value,
  96. propsTreeLabel: "deptName",
  97. propsTreeValue: "deptId",
  98. itemWidth: 50,
  99. disabled: true,
  100. },
  101. {
  102. type: "select",
  103. prop: "applyItem",
  104. label: "申请项目",
  105. filterable: true,
  106. multiple: true,
  107. data: [
  108. {
  109. label: "医保",
  110. value: "医保",
  111. },
  112. {
  113. label: "社保",
  114. value: "社保",
  115. },
  116. ],
  117. itemWidth: 50,
  118. fn: (val) => {},
  119. },
  120. {
  121. type: "date",
  122. prop: "entryTime",
  123. itemType: "date",
  124. label: "入职日期",
  125. itemWidth: 50,
  126. disabled: false,
  127. },
  128. {
  129. type: "date",
  130. prop: "regularTime",
  131. itemType: "date",
  132. label: "转正日期",
  133. itemWidth: 50,
  134. disabled: false,
  135. },
  136. {
  137. type: "input",
  138. prop: "costBearing",
  139. itemType: "text",
  140. label: "费用承担",
  141. itemWidth: 50,
  142. disabled: true,
  143. },
  144. {
  145. type: "input",
  146. prop: "deductionMethod",
  147. itemType: "text",
  148. label: "抵扣方式",
  149. itemWidth: 50,
  150. disabled: true,
  151. },
  152. {
  153. type: "input",
  154. prop: "remark",
  155. itemType: "textarea",
  156. label: "备注栏",
  157. itemWidth: 100,
  158. disabled: false,
  159. },
  160. ];
  161. });
  162. const rules = ref({
  163. applyTime: [{ required: true, message: "请选择申请日期", trigger: "change" }],
  164. companyId: [{ required: true, message: "请选择所属公司", trigger: "change" }],
  165. deptId: [{ required: true, message: "请选择所属部门", trigger: "change" }],
  166. createUser: [{ required: true, message: "请选择申请人", trigger: "change" }],
  167. applyItem: [{ required: true, message: "请选择申请项目", trigger: "change" }],
  168. entryTime: [{ required: true, message: "请选择入职日期", trigger: "change" }],
  169. regularTime: [
  170. { required: true, message: "请选择转正日期", trigger: "change" },
  171. ],
  172. fileList: [
  173. { required: true, message: "请上传学历证明附件", trigger: "change" },
  174. ],
  175. });
  176. const isFormDetail = ref(false);
  177. if (route.query && route.query.processType && route.query.processType == 20) {
  178. isFormDetail.value = true;
  179. }
  180. const getDeptData = () => {
  181. proxy
  182. .get(isFormDetail.value ? "/tenantUser/listAll" : "/tenantUser/list", {
  183. pageNum: 1,
  184. pageSize: 10000,
  185. tenantId: proxy.useUserStore().user.tenantId,
  186. // companyId: proxy.useUserStore().user.companyId,
  187. })
  188. .then((res) => {
  189. userList.value = res.rows.map((item) => {
  190. return {
  191. label: item.nickName,
  192. value: item.userId,
  193. };
  194. });
  195. });
  196. proxy
  197. .get("/tenantDept/list", {
  198. pageNum: 1,
  199. pageSize: 9999,
  200. keyword: "",
  201. // ancestors: proxy.useUserStore().user.companyId,
  202. tenantId: proxy.useUserStore().user.tenantId,
  203. // type: 2,
  204. })
  205. .then((res) => {
  206. deptData.value = proxy.handleTree(res.data, "deptId");
  207. });
  208. };
  209. getDeptData();
  210. const getDict = () => {
  211. proxy
  212. .post("/educationConfig/page", {
  213. pageNum: 1,
  214. pageSize: 999,
  215. })
  216. .then((res) => {
  217. selectData.value = res.rows.map((x) => ({
  218. ...x,
  219. label: x.name,
  220. value: x.id,
  221. }));
  222. });
  223. };
  224. // getDict();
  225. const handleSubmit = async (isStag = false) => {
  226. if (isStag) {
  227. formData.data.applyItem = formData.data.applyItem.join(",");
  228. return true;
  229. }
  230. let flag = await formDom.value.handleSubmit(() => {});
  231. if (flag) {
  232. formData.data.applyItem = formData.data.applyItem.join(",");
  233. return true;
  234. } else {
  235. setTimeout(() => {
  236. const errorDiv = document.getElementsByClassName("is-error");
  237. errorDiv[0].scrollIntoView();
  238. }, 0);
  239. }
  240. return flag;
  241. };
  242. const dataRollback = () => {
  243. formData.data.applyItem = formData.data.applyItem.split(",");
  244. };
  245. const getFormData = () => {
  246. return proxy.deepClone(formData.data);
  247. };
  248. // 向父组件暴露
  249. defineExpose({
  250. getFormData,
  251. handleSubmit,
  252. dataRollback,
  253. });
  254. const getAllData = (businessId) => {
  255. if (businessId) {
  256. proxy.post("/medicalInsurance/detail", { id: businessId }).then((res) => {
  257. if (res.applyItem) {
  258. res.applyItem = res.applyItem.split(",");
  259. } else {
  260. res.applyItem = [];
  261. }
  262. formData.data = res;
  263. });
  264. }
  265. };
  266. onMounted(() => {
  267. formOption.disabled = judgeStatus();
  268. formData.data.applyTime = proxy.parseTime(new Date());
  269. formData.data.companyId = proxy.useUserStore().user.companyId;
  270. formData.data.deptId = proxy.useUserStore().user.dept.deptId;
  271. formData.data.createUser = proxy.useUserStore().user.userId;
  272. if (route.query.businessId) {
  273. getAllData(route.query.businessId);
  274. }
  275. // 删除莫名多出的一个textarea
  276. nextTick(() => {
  277. setTimeout(() => {
  278. let dom = document.getElementsByTagName("textarea");
  279. if (dom && dom.length > 0) {
  280. for (let i = 0; i < dom.length; i++) {
  281. if (!dom[i].className) {
  282. dom[i].style.display = "none";
  283. }
  284. }
  285. }
  286. }, 100);
  287. });
  288. });
  289. </script>
  290. <style lang="scss" scoped>
  291. </style>