index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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. <el-dialog title="配置月发生额" v-if="openSetDialog" v-model="openSetDialog" width="90%">
  21. <byForm :formConfig="formShortConfig" :formOption="formOption" v-model="setFormData.data" :rules="setRules" ref="setFormDom">
  22. <template #list>
  23. <div style="width:100%">
  24. <el-button type="primary" plain @click="handleAdd" style="margin-bottom: 16px">
  25. 添加
  26. </el-button>
  27. <el-table :data="setFormData.data.logisticsAmountList">
  28. <el-table-column label="年份" width="130" fixed="left">
  29. <template #default="{ row, $index }">
  30. <el-form-item :prop="'logisticsAmountList.' + $index + '.year'" :rules="setRules.year" :inline-message="true" class="margin-b-0">
  31. <el-date-picker v-model="row.year" type="year" placeholder="请选择" style="width: 100%" value-format="YYYY" :clearable="false"
  32. :disabled-date="disabledFn" />
  33. </el-form-item>
  34. </template>
  35. </el-table-column>
  36. <el-table-column v-for="key in 12" :key="key" :label="key+'月'" width="120">
  37. <template #default="{ row, $index }">
  38. <el-form-item :prop="'logisticsAmountList.' + $index + ('.month'+key+'Amount')" :rules="setRules.amount" :inline-message="true"
  39. class="margin-b-0">
  40. <el-input-number onmousewheel="return false;" v-model="row['month'+key+'Amount']" placeholder="请输入" style="width: 100%"
  41. :precision="2" :controls="false" :min="0" />
  42. </el-form-item>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="操作" width="60" align="center" fixed="right">
  46. <template #default="{ $index }">
  47. <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. </div>
  52. </template>
  53. </byForm>
  54. <template #footer>
  55. <el-button @click="openSetDialog=false" size="default">取 消</el-button>
  56. <el-button type="primary" @click="submitSearch()" size="default">确 定</el-button>
  57. </template>
  58. </el-dialog>
  59. </div>
  60. </template>
  61. <script setup>
  62. import { computed, ref } from "vue";
  63. import byTable from "@/components/byTable/index";
  64. import byForm from "@/components/byForm/index";
  65. import useUserStore from "@/store/modules/user";
  66. import { ElMessage, ElMessageBox } from "element-plus";
  67. import moment from "moment";
  68. const { proxy } = getCurrentInstance();
  69. const accountCurrency = ref([]);
  70. const typeData = ref([
  71. {
  72. label: "收入",
  73. value: "10",
  74. },
  75. {
  76. label: "支出",
  77. value: "20",
  78. },
  79. ]);
  80. const sourceList = ref({
  81. data: [],
  82. pagination: {
  83. total: 0,
  84. pageNum: 1,
  85. pageSize: 10,
  86. keyword: "",
  87. },
  88. });
  89. const loading = ref(false);
  90. const config = computed(() => {
  91. return [
  92. {
  93. attrs: {
  94. label: "公司名称",
  95. prop: "name",
  96. },
  97. },
  98. {
  99. attrs: {
  100. label: "税点",
  101. prop: "taxPoints",
  102. },
  103. },
  104. {
  105. attrs: {
  106. label: "开户行",
  107. prop: "accountBank",
  108. },
  109. },
  110. {
  111. attrs: {
  112. label: "开户名",
  113. prop: "accountName",
  114. },
  115. },
  116. {
  117. attrs: {
  118. label: "账号",
  119. prop: "accountNumber",
  120. },
  121. },
  122. {
  123. attrs: {
  124. label: "操作",
  125. width: "200",
  126. align: "center",
  127. },
  128. renderHTML(row) {
  129. return [
  130. {
  131. attrs: {
  132. label: "修改",
  133. type: "primary",
  134. text: true,
  135. },
  136. el: "button",
  137. click() {
  138. update(row);
  139. },
  140. },
  141. {
  142. attrs: {
  143. label: "配置月发生额",
  144. type: "primary",
  145. text: true,
  146. },
  147. el: "button",
  148. click() {
  149. handleSet(row);
  150. },
  151. },
  152. {
  153. attrs: {
  154. label: "删除",
  155. type: "danger",
  156. text: true,
  157. },
  158. el: "button",
  159. click() {
  160. proxy
  161. .msgConfirm()
  162. .then((res) => {
  163. proxy
  164. .post("/logisticsCompanyInfo/delete", {
  165. id: row.id,
  166. })
  167. .then((res) => {
  168. proxy.msgTip("操作成功", 1);
  169. getList();
  170. });
  171. })
  172. .catch((err) => {});
  173. },
  174. },
  175. ];
  176. },
  177. },
  178. ];
  179. });
  180. const corporationList = ref([]);
  181. const getList = async (req) => {
  182. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  183. loading.value = true;
  184. proxy
  185. .post("/logisticsCompanyInfo/page", sourceList.value.pagination)
  186. .then((res) => {
  187. sourceList.value.data = res.rows;
  188. sourceList.value.pagination.total = res.total;
  189. setTimeout(() => {
  190. loading.value = false;
  191. }, 200);
  192. });
  193. };
  194. getList();
  195. const modalType = ref("add");
  196. const dialogVisible = ref(false);
  197. const loadingDialog = ref(false);
  198. const submit = ref(null);
  199. const formOption = reactive({
  200. inline: true,
  201. labelWidth: 100,
  202. itemWidth: 100,
  203. rules: [],
  204. });
  205. const formConfig = computed(() => {
  206. return [
  207. {
  208. type: "title1",
  209. title: "基本信息",
  210. },
  211. {
  212. type: "input",
  213. prop: "name",
  214. label: "公司名称",
  215. required: true,
  216. itemWidth: 50,
  217. itemType: "text",
  218. },
  219. {
  220. type: "number",
  221. prop: "taxPoints",
  222. label: "税点",
  223. precision: 2,
  224. min: 0,
  225. max: 100,
  226. controls: false,
  227. itemWidth: 50,
  228. },
  229. {
  230. type: "input",
  231. prop: "accountBank",
  232. label: "开户行",
  233. itemWidth: 50,
  234. itemType: "text",
  235. },
  236. {
  237. type: "input",
  238. prop: "accountName",
  239. label: "开户名",
  240. itemWidth: 50,
  241. itemType: "text",
  242. },
  243. {
  244. type: "input",
  245. prop: "accountNumber",
  246. label: "账号",
  247. itemWidth: 50,
  248. itemType: "text",
  249. },
  250. {
  251. type: "input",
  252. prop: "jdSubjectCode",
  253. label: "金蝶核算项目编号",
  254. },
  255. {
  256. type: "input",
  257. prop: "jdSubjectName",
  258. label: "金蝶核算项目名称",
  259. },
  260. ];
  261. });
  262. const rules = ref({
  263. name: [{ required: true, message: "请输入公司名称", trigger: "blur" }],
  264. taxPoints: [{ required: true, message: "请输入税点", trigger: "blur" }],
  265. accountBank: [{ required: true, message: "请输入开户行", trigger: "blur" }],
  266. accountName: [{ required: true, message: "请输入开户名", trigger: "blur" }],
  267. accountNumber: [{ required: true, message: "请输入账号", trigger: "blur" }],
  268. });
  269. const formData = reactive({
  270. data: {
  271. accountRemainderList: [{ currency: "", remainder: undefined }],
  272. },
  273. });
  274. const openModal = (val) => {
  275. modalType.value = val;
  276. formData.data = {
  277. accountRemainderList: [{ currency: "", remainder: undefined }],
  278. };
  279. loadingDialog.value = false;
  280. dialogVisible.value = true;
  281. };
  282. const clickBalance = () => {
  283. if (
  284. formData.data.accountRemainderList &&
  285. formData.data.accountRemainderList.length > 0
  286. ) {
  287. formData.data.accountRemainderList.push({
  288. currency: "",
  289. remainder: undefined,
  290. });
  291. } else {
  292. formData.data.accountRemainderList = [
  293. { currency: "", remainder: undefined },
  294. ];
  295. }
  296. };
  297. const isRepeat = (arr) => {
  298. var hash = {};
  299. for (var i in arr) {
  300. if (hash[arr[i].currency]) return true;
  301. hash[arr[i].currency] = true;
  302. }
  303. return false;
  304. };
  305. const submitForm = () => {
  306. submit.value.handleSubmit(() => {
  307. loadingDialog.value = true;
  308. proxy.post("/logisticsCompanyInfo/" + modalType.value, formData.data).then(
  309. () => {
  310. proxy.msgTip("操作成功", 1);
  311. dialogVisible.value = false;
  312. getList();
  313. },
  314. (err) => {
  315. console.log(err);
  316. loadingDialog.value = false;
  317. }
  318. );
  319. // if (
  320. // formData.data.accountRemainderList &&
  321. // formData.data.accountRemainderList.length > 0
  322. // ) {
  323. // if (isRepeat(formData.data.accountRemainderList)) {
  324. // return ElMessage("请勿重复添加货币余额");
  325. // } else {
  326. // loadingDialog.value = true;
  327. // proxy.post("/accountManagement/" + modalType.value, formData.data).then(
  328. // () => {
  329. // ElMessage({
  330. // message: modalType.value == "add" ? "添加成功" : "编辑成功",
  331. // type: "success",
  332. // });
  333. // dialogVisible.value = false;
  334. // getList();
  335. // },
  336. // (err) => {
  337. // console.log(err);
  338. // loadingDialog.value = false;
  339. // }
  340. // );
  341. // }
  342. // } else {
  343. // return ElMessage("请添加至少一条类型余额");
  344. // }
  345. });
  346. };
  347. const update = (row) => {
  348. loadingDialog.value = false;
  349. modalType.value = "edit";
  350. formData.data = proxy.deepClone(row);
  351. dialogVisible.value = true;
  352. };
  353. const openSetDialog = ref(false);
  354. const setFormData = reactive({
  355. data: {},
  356. });
  357. const setFormDom = ref(null);
  358. const formShortConfig = computed(() => {
  359. return [
  360. {
  361. type: "title1",
  362. title: "发生额明细",
  363. },
  364. {
  365. type: "slot",
  366. slotName: "list",
  367. label: "",
  368. },
  369. ];
  370. });
  371. const setRules = ref({
  372. // amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
  373. year: [{ required: true, message: "请输入年份", trigger: "blur" }],
  374. });
  375. const rowData = ref({});
  376. const handleSet = (row) => {
  377. rowData.value = row;
  378. openSetDialog.value = true;
  379. proxy
  380. .post("/logisticsAmount/list", { logisticsCompanyId: row.id })
  381. .then((res) => {
  382. setFormData.data = {
  383. logisticsCompanyId: row.id,
  384. logisticsAmountList: res.map((x) => ({ ...x, year: x.year + "" })),
  385. };
  386. });
  387. };
  388. const handleAdd = () => {
  389. setFormData.data.logisticsAmountList.push({
  390. logisticsCompanyId: rowData.value.id,
  391. year: "",
  392. });
  393. };
  394. const handleRemove = (index) => {
  395. setFormData.data.logisticsAmountList.splice(index, 1);
  396. };
  397. const submitSearch = () => {
  398. setFormDom.value.handleSubmit(() => {
  399. if (
  400. !(
  401. setFormData.data.logisticsAmountList &&
  402. setFormData.data.logisticsAmountList.length > 0
  403. )
  404. ) {
  405. return proxy.msgTip("请添加发生额明细", 2);
  406. }
  407. proxy.post("/logisticsAmount/saveOrEditList", setFormData.data).then(
  408. () => {
  409. proxy.msgTip("操作成功");
  410. openSetDialog.value = false;
  411. // getList();
  412. },
  413. (err) => {
  414. console.log(err);
  415. }
  416. );
  417. });
  418. };
  419. const currentDate = computed(
  420. () => setFormData.data.logisticsAmountList.map((x) => x.year) || []
  421. );
  422. const disabledFn = (date) => {
  423. // 当前年份
  424. let current = moment(date).format("yyyy");
  425. // 禁用已选年份
  426. return currentDate.value.includes(current);
  427. };
  428. </script>
  429. <style lang="scss" scoped>
  430. .tenant {
  431. padding: 20px;
  432. }
  433. ::v-deep(.el-input-number .el-input__inner) {
  434. text-align: left;
  435. }
  436. </style>