index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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 sealType = computed(() => proxy.useUserStore().allDict["seal_type"]);
  30. const userList = ref([]);
  31. const deptData = ref([]);
  32. const typeData = ref([
  33. {
  34. label: "收入",
  35. value: "10",
  36. },
  37. {
  38. label: "支出",
  39. value: "20",
  40. },
  41. ]);
  42. const sourceList = ref({
  43. data: [],
  44. pagination: {
  45. total: 0,
  46. pageNum: 1,
  47. pageSize: 10,
  48. keyword: "",
  49. },
  50. });
  51. const loading = ref(false);
  52. const config = computed(() => {
  53. return [
  54. {
  55. attrs: {
  56. label: "印章名称",
  57. prop: "name",
  58. },
  59. },
  60. {
  61. attrs: {
  62. label: "印章类型",
  63. prop: "type",
  64. },
  65. render(val) {
  66. return proxy.dictKeyValue(val, sealType.value);
  67. },
  68. },
  69. {
  70. attrs: {
  71. label: "存管人员",
  72. prop: "accountBank",
  73. },
  74. },
  75. {
  76. attrs: {
  77. label: "存管部门",
  78. prop: "accountName",
  79. },
  80. },
  81. {
  82. attrs: {
  83. label: "印章用途",
  84. prop: "印章用途",
  85. },
  86. },
  87. {
  88. attrs: {
  89. label: "操作",
  90. width: "120",
  91. align: "center",
  92. },
  93. renderHTML(row) {
  94. return [
  95. {
  96. attrs: {
  97. label: "修改",
  98. type: "primary",
  99. text: true,
  100. },
  101. el: "button",
  102. click() {
  103. update(row);
  104. },
  105. },
  106. {
  107. attrs: {
  108. label: "删除",
  109. type: "danger",
  110. text: true,
  111. },
  112. el: "button",
  113. click() {
  114. proxy
  115. .msgConfirm()
  116. .then((res) => {
  117. proxy
  118. .post("/contractor/delete", {
  119. id: row.id,
  120. })
  121. .then((res) => {
  122. proxy.msgTip("操作成功", 1);
  123. getList();
  124. });
  125. })
  126. .catch((err) => {});
  127. },
  128. },
  129. ];
  130. },
  131. },
  132. ];
  133. });
  134. const corporationList = ref([]);
  135. const getList = async (req) => {
  136. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  137. loading.value = true;
  138. proxy.post("/contractor/page", sourceList.value.pagination).then((res) => {
  139. sourceList.value.data = res.rows;
  140. sourceList.value.pagination.total = res.total;
  141. setTimeout(() => {
  142. loading.value = false;
  143. }, 200);
  144. });
  145. };
  146. getList();
  147. const getDeptData = (val) => {
  148. proxy
  149. .get("/tenantUser/list", {
  150. pageNum: 1,
  151. pageSize: 10000,
  152. tenantId: proxy.useUserStore().user.tenantId,
  153. companyId: proxy.useUserStore().user.companyId,
  154. })
  155. .then((res) => {
  156. userList.value = res.rows.map((item) => {
  157. return {
  158. ...item,
  159. label: item.nickName,
  160. value: item.userId,
  161. };
  162. });
  163. });
  164. proxy
  165. .get("/tenantDept/list", {
  166. pageNum: 1,
  167. pageSize: 9999,
  168. keyword: "",
  169. ancestors: proxy.useUserStore().user.companyId,
  170. tenantId: proxy.useUserStore().user.tenantId,
  171. // type: 2,
  172. })
  173. .then((res) => {
  174. deptData.value = proxy.handleTree(res.data, "deptId");
  175. });
  176. };
  177. getDeptData();
  178. const modalType = ref("add");
  179. const dialogVisible = ref(false);
  180. const loadingDialog = ref(false);
  181. const submit = ref(null);
  182. const formOption = reactive({
  183. inline: true,
  184. labelWidth: 100,
  185. itemWidth: 100,
  186. rules: [],
  187. });
  188. const formConfig = computed(() => {
  189. return [
  190. {
  191. type: "title1",
  192. title: "基本信息",
  193. },
  194. {
  195. type: "input",
  196. prop: "name",
  197. label: "印章名称",
  198. required: true,
  199. itemWidth: 50,
  200. itemType: "text",
  201. },
  202. {
  203. type: "select",
  204. prop: "sealType",
  205. label: "印章类型",
  206. data: sealType.value,
  207. itemWidth: 50,
  208. },
  209. {
  210. type: "select",
  211. prop: "applyUserId",
  212. label: "存管人员",
  213. required: true,
  214. filterable: true,
  215. data: userList.value,
  216. itemWidth: 50,
  217. fn: (val) => {
  218. let current = userList.value.find((x) => x.value == val);
  219. console.log(current, "ada");
  220. if (current) {
  221. formData.data.deptId = current.deptId;
  222. }
  223. },
  224. },
  225. {
  226. type: "treeSelect",
  227. prop: "deptId",
  228. label: "存管部门",
  229. data: deptData.value,
  230. propsTreeLabel: "deptName",
  231. propsTreeValue: "deptId",
  232. itemWidth: 50,
  233. disabled: 50,
  234. },
  235. {
  236. type: "input",
  237. prop: "accountNumber",
  238. label: "印章用途",
  239. itemWidth: 100,
  240. itemType: "textarea",
  241. },
  242. ];
  243. });
  244. const rules = ref({
  245. name: [{ required: true, message: "请输入承包商", trigger: "blur" }],
  246. taxPoints: [{ required: true, message: "请输入税点", trigger: "blur" }],
  247. accountBank: [{ required: true, message: "请输入开户行", trigger: "blur" }],
  248. accountName: [{ required: true, message: "请输入开户名", trigger: "blur" }],
  249. accountNumber: [{ required: true, message: "请输入账号", trigger: "blur" }],
  250. });
  251. const formData = reactive({
  252. data: {
  253. accountRemainderList: [{ currency: "", remainder: undefined }],
  254. },
  255. });
  256. const openModal = (val) => {
  257. modalType.value = val;
  258. formData.data = {
  259. accountRemainderList: [{ currency: "", remainder: undefined }],
  260. };
  261. loadingDialog.value = false;
  262. dialogVisible.value = true;
  263. };
  264. const clickBalance = () => {
  265. if (
  266. formData.data.accountRemainderList &&
  267. formData.data.accountRemainderList.length > 0
  268. ) {
  269. formData.data.accountRemainderList.push({
  270. currency: "",
  271. remainder: undefined,
  272. });
  273. } else {
  274. formData.data.accountRemainderList = [
  275. { currency: "", remainder: undefined },
  276. ];
  277. }
  278. };
  279. const handleRemove = (index) => {
  280. formData.data.accountRemainderList.splice(index, 1);
  281. };
  282. const isRepeat = (arr) => {
  283. var hash = {};
  284. for (var i in arr) {
  285. if (hash[arr[i].currency]) return true;
  286. hash[arr[i].currency] = true;
  287. }
  288. return false;
  289. };
  290. const submitForm = () => {
  291. submit.value.handleSubmit(() => {
  292. loadingDialog.value = true;
  293. proxy.post("/contractor/" + modalType.value, formData.data).then(
  294. () => {
  295. proxy.msgTip("操作成功", 1);
  296. dialogVisible.value = false;
  297. getList();
  298. },
  299. (err) => {
  300. console.log(err);
  301. loadingDialog.value = false;
  302. }
  303. );
  304. // if (
  305. // formData.data.accountRemainderList &&
  306. // formData.data.accountRemainderList.length > 0
  307. // ) {
  308. // if (isRepeat(formData.data.accountRemainderList)) {
  309. // return ElMessage("请勿重复添加货币余额");
  310. // } else {
  311. // loadingDialog.value = true;
  312. // proxy.post("/accountManagement/" + modalType.value, formData.data).then(
  313. // () => {
  314. // ElMessage({
  315. // message: modalType.value == "add" ? "添加成功" : "编辑成功",
  316. // type: "success",
  317. // });
  318. // dialogVisible.value = false;
  319. // getList();
  320. // },
  321. // (err) => {
  322. // console.log(err);
  323. // loadingDialog.value = false;
  324. // }
  325. // );
  326. // }
  327. // } else {
  328. // return ElMessage("请添加至少一条类型余额");
  329. // }
  330. });
  331. };
  332. const update = (row) => {
  333. loadingDialog.value = false;
  334. modalType.value = "edit";
  335. formData.data = proxy.deepClone(row);
  336. dialogVisible.value = true;
  337. };
  338. </script>
  339. <style lang="scss" scoped>
  340. .tenant {
  341. padding: 20px;
  342. }
  343. ::v-deep(.el-input-number .el-input__inner) {
  344. text-align: left;
  345. }
  346. </style>