index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="pageIndexClass">
  3. <div class="content">
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row :action-list="[
  5. {
  6. text: '添加',
  7. action: () => openModal('add'),
  8. },
  9. ]" @get-list="getList">
  10. </byTable>
  11. </div>
  12. <el-dialog :title="modalType == 'add' ? '添加' : '编辑'" v-if="dialogVisible" v-model="dialogVisible" width="500">
  13. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit" v-loading="loadingDialog">
  14. </byForm>
  15. <template #footer>
  16. <el-button @click="dialogVisible = false" size="default">取 消</el-button>
  17. <el-button type="primary" @click="submitForm()" size="default">确 定</el-button>
  18. </template>
  19. </el-dialog>
  20. </div>
  21. </template>
  22. <script setup>
  23. import { computed, ref } from "vue";
  24. import byTable from "@/components/byTable/index";
  25. import byForm from "@/components/byForm/index";
  26. import useUserStore from "@/store/modules/user";
  27. import { ElMessage, ElMessageBox } from "element-plus";
  28. const { proxy } = getCurrentInstance();
  29. const accountCurrency = ref([]);
  30. const typeData = ref([
  31. {
  32. label: "收入",
  33. value: "10",
  34. },
  35. {
  36. label: "支出",
  37. value: "20",
  38. },
  39. ]);
  40. const sourceList = ref({
  41. data: [],
  42. pagination: {
  43. total: 0,
  44. pageNum: 1,
  45. pageSize: 10,
  46. keyword: "",
  47. },
  48. });
  49. const loading = ref(false);
  50. const config = computed(() => {
  51. return [
  52. {
  53. attrs: {
  54. label: "学历名称",
  55. prop: "name",
  56. },
  57. },
  58. {
  59. attrs: {
  60. label: "学历补贴金额",
  61. prop: "amount",
  62. },
  63. render(val) {
  64. return proxy.moneyFormat(val, 2);
  65. },
  66. },
  67. {
  68. attrs: {
  69. label: "操作",
  70. width: "120",
  71. align: "center",
  72. },
  73. renderHTML(row) {
  74. return [
  75. {
  76. attrs: {
  77. label: "修改",
  78. type: "primary",
  79. text: true,
  80. },
  81. el: "button",
  82. click() {
  83. update(row);
  84. },
  85. },
  86. {
  87. attrs: {
  88. label: "删除",
  89. type: "danger",
  90. text: true,
  91. },
  92. el: "button",
  93. click() {
  94. proxy
  95. .msgConfirm()
  96. .then((res) => {
  97. proxy
  98. .post("/educationConfig/delete", {
  99. id: row.id,
  100. })
  101. .then((res) => {
  102. proxy.msgTip("操作成功", 1);
  103. getList();
  104. });
  105. })
  106. .catch((err) => {});
  107. },
  108. },
  109. ];
  110. },
  111. },
  112. ];
  113. });
  114. const corporationList = ref([]);
  115. const getList = async (req) => {
  116. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  117. loading.value = true;
  118. proxy
  119. .post("/educationConfig/page", sourceList.value.pagination)
  120. .then((res) => {
  121. sourceList.value.data = res.rows;
  122. sourceList.value.pagination.total = res.total;
  123. setTimeout(() => {
  124. loading.value = false;
  125. }, 200);
  126. });
  127. };
  128. getList();
  129. const modalType = ref("add");
  130. const dialogVisible = ref(false);
  131. const loadingDialog = ref(false);
  132. const submit = ref(null);
  133. const formOption = reactive({
  134. inline: true,
  135. labelWidth: 110,
  136. itemWidth: 100,
  137. rules: [],
  138. });
  139. const formConfig = computed(() => {
  140. return [
  141. {
  142. type: "title1",
  143. title: "基本信息",
  144. },
  145. {
  146. type: "input",
  147. prop: "name",
  148. label: "学历名称",
  149. required: true,
  150. itemWidth: 100,
  151. itemType: "text",
  152. },
  153. {
  154. type: "number",
  155. prop: "amount",
  156. label: "学历补贴金额",
  157. precision: 2,
  158. min: 0,
  159. // max: 100,
  160. controls: false,
  161. itemWidth: 100,
  162. },
  163. ];
  164. });
  165. const rules = ref({
  166. name: [{ required: true, message: "请输入学历名称", trigger: "blur" }],
  167. amount: [{ required: true, message: "请输入学历补贴金额", trigger: "blur" }],
  168. });
  169. const formData = reactive({
  170. data: {},
  171. });
  172. const openModal = (val) => {
  173. modalType.value = val;
  174. formData.data = {};
  175. loadingDialog.value = false;
  176. dialogVisible.value = true;
  177. };
  178. const clickBalance = () => {
  179. if (
  180. formData.data.accountRemainderList &&
  181. formData.data.accountRemainderList.length > 0
  182. ) {
  183. formData.data.accountRemainderList.push({
  184. currency: "",
  185. remainder: undefined,
  186. });
  187. } else {
  188. formData.data.accountRemainderList = [
  189. { currency: "", remainder: undefined },
  190. ];
  191. }
  192. };
  193. const handleRemove = (index) => {
  194. formData.data.accountRemainderList.splice(index, 1);
  195. };
  196. const isRepeat = (arr) => {
  197. var hash = {};
  198. for (var i in arr) {
  199. if (hash[arr[i].currency]) return true;
  200. hash[arr[i].currency] = true;
  201. }
  202. return false;
  203. };
  204. const submitForm = () => {
  205. submit.value.handleSubmit(() => {
  206. loadingDialog.value = true;
  207. proxy.post("/educationConfig/" + modalType.value, formData.data).then(
  208. () => {
  209. proxy.msgTip("操作成功", 1);
  210. dialogVisible.value = false;
  211. getList();
  212. },
  213. (err) => {
  214. console.log(err);
  215. loadingDialog.value = false;
  216. }
  217. );
  218. // if (
  219. // formData.data.accountRemainderList &&
  220. // formData.data.accountRemainderList.length > 0
  221. // ) {
  222. // if (isRepeat(formData.data.accountRemainderList)) {
  223. // return ElMessage("请勿重复添加货币余额");
  224. // } else {
  225. // loadingDialog.value = true;
  226. // proxy.post("/accountManagement/" + modalType.value, formData.data).then(
  227. // () => {
  228. // ElMessage({
  229. // message: modalType.value == "add" ? "添加成功" : "编辑成功",
  230. // type: "success",
  231. // });
  232. // dialogVisible.value = false;
  233. // getList();
  234. // },
  235. // (err) => {
  236. // console.log(err);
  237. // loadingDialog.value = false;
  238. // }
  239. // );
  240. // }
  241. // } else {
  242. // return ElMessage("请添加至少一条类型余额");
  243. // }
  244. });
  245. };
  246. const update = (row) => {
  247. loadingDialog.value = false;
  248. modalType.value = "edit";
  249. formData.data = proxy.deepClone(row);
  250. dialogVisible.value = true;
  251. };
  252. </script>
  253. <style lang="scss" scoped>
  254. .tenant {
  255. padding: 20px;
  256. }
  257. ::v-deep(.el-input-number .el-input__inner) {
  258. text-align: left;
  259. }
  260. </style>