index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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="60%">
  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: "taxPoints",
  62. },
  63. },
  64. {
  65. attrs: {
  66. label: "开户行",
  67. prop: "accountBank",
  68. },
  69. },
  70. {
  71. attrs: {
  72. label: "开户名",
  73. prop: "accountName",
  74. },
  75. },
  76. {
  77. attrs: {
  78. label: "账号",
  79. prop: "accountNumber",
  80. },
  81. },
  82. {
  83. attrs: {
  84. label: "操作",
  85. width: "120",
  86. align: "center",
  87. },
  88. renderHTML(row) {
  89. return [
  90. {
  91. attrs: {
  92. label: "修改",
  93. type: "primary",
  94. text: true,
  95. },
  96. el: "button",
  97. click() {
  98. update(row);
  99. },
  100. },
  101. {
  102. attrs: {
  103. label: "删除",
  104. type: "danger",
  105. text: true,
  106. },
  107. el: "button",
  108. click() {
  109. proxy
  110. .msgConfirm()
  111. .then((res) => {
  112. proxy
  113. .post("/contractor/delete", {
  114. id: row.id,
  115. })
  116. .then((res) => {
  117. proxy.msgTip("操作成功", 1);
  118. getList();
  119. });
  120. })
  121. .catch((err) => {});
  122. },
  123. },
  124. ];
  125. },
  126. },
  127. ];
  128. });
  129. const corporationList = ref([]);
  130. const getList = async (req) => {
  131. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  132. loading.value = true;
  133. proxy.post("/contractor/page", sourceList.value.pagination).then((res) => {
  134. sourceList.value.data = res.rows;
  135. sourceList.value.pagination.total = res.total;
  136. setTimeout(() => {
  137. loading.value = false;
  138. }, 200);
  139. });
  140. };
  141. getList();
  142. const modalType = ref("add");
  143. const dialogVisible = ref(false);
  144. const loadingDialog = ref(false);
  145. const submit = ref(null);
  146. const formOption = reactive({
  147. inline: true,
  148. labelWidth: 100,
  149. itemWidth: 100,
  150. rules: [],
  151. });
  152. const formConfig = computed(() => {
  153. return [
  154. {
  155. type: "title1",
  156. title: "基本信息",
  157. },
  158. {
  159. type: "input",
  160. prop: "name",
  161. label: "承包商",
  162. required: true,
  163. itemWidth: 50,
  164. itemType: "text",
  165. },
  166. {
  167. type: "number",
  168. prop: "taxPoints",
  169. label: "税点",
  170. precision: 2,
  171. min: 0,
  172. max: 100,
  173. controls: false,
  174. itemWidth: 50,
  175. },
  176. {
  177. type: "input",
  178. prop: "accountBank",
  179. label: "开户行",
  180. itemWidth: 50,
  181. itemType: "text",
  182. },
  183. {
  184. type: "input",
  185. prop: "accountName",
  186. label: "开户名",
  187. itemWidth: 50,
  188. itemType: "text",
  189. },
  190. {
  191. type: "input",
  192. prop: "accountNumber",
  193. label: "账号",
  194. itemWidth: 50,
  195. itemType: "text",
  196. },
  197. {
  198. type: "input",
  199. prop: "jdSubjectCode",
  200. label: "核算项目编号",
  201. },
  202. {
  203. type: "input",
  204. prop: "jdSubjectName",
  205. label: "核算项目名称",
  206. },
  207. ];
  208. });
  209. const rules = ref({
  210. name: [{ required: true, message: "请输入承包商", trigger: "blur" }],
  211. taxPoints: [{ required: true, message: "请输入税点", trigger: "blur" }],
  212. accountBank: [{ required: true, message: "请输入开户行", trigger: "blur" }],
  213. accountName: [{ required: true, message: "请输入开户名", trigger: "blur" }],
  214. accountNumber: [{ required: true, message: "请输入账号", trigger: "blur" }],
  215. });
  216. const formData = reactive({
  217. data: {
  218. accountRemainderList: [{ currency: "", remainder: undefined }],
  219. },
  220. });
  221. const openModal = (val) => {
  222. modalType.value = val;
  223. formData.data = {
  224. accountRemainderList: [{ currency: "", remainder: undefined }],
  225. };
  226. loadingDialog.value = false;
  227. dialogVisible.value = true;
  228. };
  229. const clickBalance = () => {
  230. if (
  231. formData.data.accountRemainderList &&
  232. formData.data.accountRemainderList.length > 0
  233. ) {
  234. formData.data.accountRemainderList.push({
  235. currency: "",
  236. remainder: undefined,
  237. });
  238. } else {
  239. formData.data.accountRemainderList = [
  240. { currency: "", remainder: undefined },
  241. ];
  242. }
  243. };
  244. const handleRemove = (index) => {
  245. formData.data.accountRemainderList.splice(index, 1);
  246. };
  247. const isRepeat = (arr) => {
  248. var hash = {};
  249. for (var i in arr) {
  250. if (hash[arr[i].currency]) return true;
  251. hash[arr[i].currency] = true;
  252. }
  253. return false;
  254. };
  255. const submitForm = () => {
  256. submit.value.handleSubmit(() => {
  257. loadingDialog.value = true;
  258. proxy.post("/contractor/" + modalType.value, formData.data).then(
  259. () => {
  260. proxy.msgTip("操作成功", 1);
  261. dialogVisible.value = false;
  262. getList();
  263. },
  264. (err) => {
  265. console.log(err);
  266. loadingDialog.value = false;
  267. }
  268. );
  269. // if (
  270. // formData.data.accountRemainderList &&
  271. // formData.data.accountRemainderList.length > 0
  272. // ) {
  273. // if (isRepeat(formData.data.accountRemainderList)) {
  274. // return ElMessage("请勿重复添加货币余额");
  275. // } else {
  276. // loadingDialog.value = true;
  277. // proxy.post("/accountManagement/" + modalType.value, formData.data).then(
  278. // () => {
  279. // ElMessage({
  280. // message: modalType.value == "add" ? "添加成功" : "编辑成功",
  281. // type: "success",
  282. // });
  283. // dialogVisible.value = false;
  284. // getList();
  285. // },
  286. // (err) => {
  287. // console.log(err);
  288. // loadingDialog.value = false;
  289. // }
  290. // );
  291. // }
  292. // } else {
  293. // return ElMessage("请添加至少一条类型余额");
  294. // }
  295. });
  296. };
  297. const update = (row) => {
  298. loadingDialog.value = false;
  299. modalType.value = "edit";
  300. formData.data = proxy.deepClone(row);
  301. dialogVisible.value = true;
  302. };
  303. </script>
  304. <style lang="scss" scoped>
  305. .tenant {
  306. padding: 20px;
  307. }
  308. ::v-deep(.el-input-number .el-input__inner) {
  309. text-align: left;
  310. }
  311. </style>