index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <template>
  2. <LjFoldLayout ref="LjFoldLayoutRef" v-bind="layoutSetting">
  3. <div class="main-box flx-col">
  4. <LjVxeTable
  5. ref="vxeTableRef"
  6. row-key="bednetid"
  7. :columns="columns"
  8. :init-param="initParams"
  9. :request-api="getData"
  10. :data-callback="dataCallback"
  11. :dwname="DwnameEnum.bednetQuote"
  12. :table-props="tableProps"
  13. :table-events="tableEvents"
  14. :auto-load-layout="false"
  15. :search-btn-size-extent="[]"
  16. pagination
  17. @on-mounted-data="autoMonthedData"
  18. >
  19. <!-- 表格 header 按钮 -->
  20. <template #tableHeader>
  21. <LjHeaderMenu :update="dialogVisible" :action="action" />
  22. <!-- <el-button-group>
  23. <el-button @click="toAdd">{{ $t("common.add") }}</el-button>
  24. <el-button @click="toDel">{{ $t("common.delText") }}</el-button>
  25. <el-button @click="toA">{{ $t("common.auditFinance") }}</el-button>
  26. <el-button @click="toAdd">{{ $t("common.copyQuote") }}</el-button>
  27. <el-button @click="toAdd">{{ $t("common.businessOrder") }}</el-button>
  28. <el-button @click="toAdd">{{ $t("common.viewHistoricalQuotes") }}</el-button>
  29. </el-button-group> -->
  30. </template>
  31. </LjVxeTable>
  32. </div>
  33. <template #right>
  34. <div class="main-box flx card">
  35. <LjVxeTable
  36. ref="vxeTableMxRef"
  37. row-key="bednetmxid"
  38. table-cls="overflow-hidden pr-16"
  39. :columns="columnsMx"
  40. :init-param="initParamsMx"
  41. :request-api="getDataMx"
  42. :data-callback="dataCallback"
  43. :dwname="DwnameEnum.bednetQuoteMx"
  44. :table-props="tableProps"
  45. :table-events="tableEventsMx"
  46. :auto-load-layout="false"
  47. :search-btn-size-extent="[]"
  48. collapseButtons
  49. :request-auto="false"
  50. >
  51. <template #tableHeader>
  52. <LjHeader class="flx-1" title="床网多网明细" />
  53. </template>
  54. </LjVxeTable>
  55. <div class="flx flx-shrink h-full" style="min-width: 542px">
  56. <LjVxeTable
  57. ref="vxeTableMxSpringRef"
  58. row-key="bednetmx_partid"
  59. table-cls=""
  60. :columns="columnsMxSpring"
  61. :init-param="initParamsMxSpring"
  62. :request-api="getDataMxSpring"
  63. :data-callback="dataCallback"
  64. :dwname="DwnameEnum.bednetQuoteMxSpring"
  65. :table-props="tableProps"
  66. :auto-load-layout="false"
  67. :search-btn-size-extent="[]"
  68. collapseButtons
  69. :request-auto="false"
  70. >
  71. <template #tableHeader>
  72. <LjHeader class="flx-1" title="多区袋装明细" />
  73. </template>
  74. </LjVxeTable>
  75. </div>
  76. </div>
  77. </template>
  78. </LjFoldLayout>
  79. </template>
  80. <script setup lang="ts" name="bednetQuote">
  81. import { ref, onMounted, inject } from "vue";
  82. import { useRouter } from "vue-router";
  83. import { AuditBedNet, DeleteBedNet, ReCalculateBedNetNoAudit } from "@/api/modules/quote";
  84. import { CommonDynamicSelect } from "@/api/modules/common";
  85. import { ColumnProps } from "@/components/LjVxeTable/interface";
  86. import LjDrawer from "@/components/LjDrawer/index.vue";
  87. // import PriceListDetail from "./detail.vue";
  88. import { useHooks } from "./hooks/index";
  89. import LjDialog from "@/components/LjDialog/index.vue";
  90. import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
  91. import { useI18n } from "vue-i18n";
  92. import { useAuthButtons } from "@/hooks/useAuthButtons";
  93. import { DwnameEnum } from "@/enums/dwnameEnum";
  94. import { formatToDateTime, formatToDate } from "@/utils/dateUtil";
  95. import { cloneDeep } from "lodash-es";
  96. import { useGlobalStore } from "@/stores/modules/global";
  97. import { ElMessage, ElMessageBox } from "element-plus";
  98. import { detailAction } from "@/components/LjDetail/interface";
  99. import mittBus from "@/utils/mittBus";
  100. import { MittEnum } from "@/enums/mittEnum";
  101. import { getCurrentRecords } from "@/utils/index";
  102. import LjFoldLayout from "@/components/LjFoldLayout/index.vue";
  103. const { t } = useI18n();
  104. const router = useRouter();
  105. const globalStore = useGlobalStore();
  106. const {
  107. columns,
  108. columnsMx,
  109. columnsMxSpring,
  110. initParams,
  111. initParamsMx,
  112. initParamsMxSpring,
  113. getData,
  114. getDataMx,
  115. getDataMxSpring,
  116. dataCallback
  117. } = useHooks();
  118. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  119. const dialogVisible = ref(false);
  120. const vxeTableRef = ref();
  121. const vxeTableMxRef = ref();
  122. const vxeTableMxSpringRef = ref();
  123. const LjFoldLayoutRef = ref();
  124. const layoutSetting = {
  125. dwname: DwnameEnum.bednetQuote,
  126. direction: "vertical",
  127. right: {
  128. // hidden: true
  129. }
  130. };
  131. const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  132. if (globalStore.detailBlank) {
  133. // 打开新的窗口
  134. const routeUrl = router.resolve({
  135. path: `/bednetQuote/detail`,
  136. query: {
  137. id: row.bednetid,
  138. code: row.bednetcode
  139. }
  140. });
  141. window.open(routeUrl.href, "_blank");
  142. } else {
  143. // if (currentLayout.value.right.hidden && globalStore.mxFloat?.includes("custCrmDetail")) {
  144. // // 弹窗
  145. // mainData.value = row;
  146. // LjDrawerRef.value.show();
  147. // } else {
  148. // 打开新的标签页
  149. router.push(`/bednetQuote/detail?id=${row.bednetid}&code=${row.bednetcode}`);
  150. // }
  151. }
  152. };
  153. const handleClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  154. initParamsMx.value.arg_bednetid = row.bednetid;
  155. };
  156. const rowClsNameFunc = (data: any) => {
  157. const { row, rowIndex, $rowIndex } = data;
  158. if (row.flag == "0") {
  159. return "vxecol-danger";
  160. }
  161. return "";
  162. };
  163. const tableProps = {
  164. height: "auto",
  165. editConfig: { trigger: "click", mode: "cell" },
  166. rowClassName: rowClsNameFunc
  167. // exportConfig: {
  168. // filename: t("menu.saletaskmx") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  169. // }
  170. };
  171. const autoMonthedData = (data: any) => {
  172. const $table = vxeTableRef.value.element;
  173. console.log("autoMonthedData 123:>> ", $table);
  174. if ($table) {
  175. let { fullData } = $table.getTableData();
  176. console.log("object :>> ", $table.getTableData());
  177. if (fullData.length > 0) {
  178. $table.setCurrentRow(fullData[0]);
  179. initParamsMx.value.arg_bednetid = fullData[0].bednetid;
  180. }
  181. }
  182. };
  183. const handleClickTableMx = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  184. initParamsMxSpring.value.arg_bednetmxid = row.bednetmxid;
  185. };
  186. // 返回绑定的事件
  187. const tableEvents = {
  188. "cell-dblclick": handleDBlClickTable,
  189. "cell-click": handleClickTable
  190. };
  191. // 返回绑定的事件
  192. const tableEventsMx = {
  193. "cell-click": handleClickTableMx
  194. };
  195. /**
  196. * @description 按钮展示
  197. */
  198. const action: detailAction[] = [
  199. buttonDefault({
  200. label: t("common.redo"),
  201. clickFunc: item => {
  202. vxeTableRef.value.refresh();
  203. }
  204. }),
  205. buttonDefault({
  206. label: t("common.add"),
  207. power: 62,
  208. clickFunc: item => {
  209. console.log("inewss nitParams.value :>> ", vxeTableRef.value.searchParam);
  210. let _deptid = 0;
  211. if (Object.keys(vxeTableRef.value.searchParam).includes("arg_deptid")) {
  212. _deptid = vxeTableRef.value.searchParam.arg_deptid;
  213. }
  214. router.push(`/bednetQuote/new?id=0&deptid=${_deptid}`);
  215. }
  216. }),
  217. buttonDefault({
  218. label: t("common.editText"),
  219. power: 62,
  220. clickFunc: item => {
  221. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  222. if (!curRecords.length) {
  223. ElMessage.warning(t("business.tips.mattress.records"));
  224. return;
  225. }
  226. const _cur = $table.getCurrentRecord() ?? null;
  227. console.log("_cur!!! :>> ", _cur);
  228. if (_cur) {
  229. router.push(`/bednetQuote/edit?id=${_cur.bednetid}&code=${_cur.bednetcode}`);
  230. } else {
  231. const _cur = curRecords[curRecords.length - 1];
  232. router.push(`/bednetQuote/edit?id=${_cur.bednetid}&code=${_cur.bednetcode}`);
  233. }
  234. }
  235. }),
  236. buttonDefault({
  237. label: t("common.delText"),
  238. power: 76,
  239. disabledTextCallBack: (data: any) => {
  240. if (!CheckPower(76)) {
  241. return "你没有【报价单-删除】的使用权限";
  242. }
  243. return "";
  244. },
  245. clickFunc: item => {
  246. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  247. console.log("curRecords :>> ", curRecords);
  248. if (!curRecords.length) {
  249. ElMessage.warning(t("business.tips.mattress.records"));
  250. return;
  251. }
  252. ElMessageBox.confirm(`是否确定要删除${curRecords.length}张报价单吗?`, "询问", {
  253. confirmButtonText: t("common.delText"),
  254. cancelButtonText: "否",
  255. type: "warning"
  256. })
  257. .then(() => {
  258. let list = curRecords.map((item: any) => {
  259. return { bednetid: Number(item.bednetid) };
  260. });
  261. DeleteBedNet({ list }).then(() => {
  262. ElMessage.success("删除成功!");
  263. vxeTableRef.value.refresh();
  264. });
  265. })
  266. .catch((e: TypeError) => {
  267. console.log("e :>> ", e);
  268. ElMessage({
  269. type: "info",
  270. message: "操作取消"
  271. });
  272. });
  273. }
  274. }),
  275. [
  276. buttonDefault({
  277. label: t("common.auditText"),
  278. power: 63,
  279. disabledTextCallBack: (data: any) => {
  280. if (!CheckPower(63)) {
  281. return `你没有【报价单-${t("common.auditText")}】的使用权限`;
  282. }
  283. return "";
  284. },
  285. clickFunc: item => {
  286. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  287. ElMessageBox.confirm("是否确定要审核单据吗?", "询问", {
  288. confirmButtonText: "是",
  289. cancelButtonText: "否",
  290. type: "warning"
  291. })
  292. .then(() => {
  293. let list = curRecords.map((item: any) => {
  294. return { bednetid: Number(item.bednetid) };
  295. });
  296. AuditBedNet({ list, type: 1 }).then(() => {
  297. ElMessage.success("审核成功!");
  298. vxeTableRef.value.refresh();
  299. });
  300. })
  301. .catch((e: TypeError) => {
  302. ElMessage({
  303. type: "info",
  304. message: "操作取消"
  305. });
  306. });
  307. }
  308. }),
  309. buttonDefault({
  310. label: t("common.withdrawAuditText"),
  311. power: 64,
  312. disabledTextCallBack: (data: any) => {
  313. if (!CheckPower(64)) {
  314. return `你没有【报价单-${t("common.withdrawAuditText")}】的使用权限`;
  315. }
  316. return "";
  317. },
  318. clickFunc: item => {
  319. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  320. ElMessageBox.confirm("是否确定要撤审单据吗?", "询问", {
  321. confirmButtonText: "是",
  322. cancelButtonText: "否",
  323. type: "warning"
  324. })
  325. .then(() => {
  326. let list = curRecords.map((item: any) => {
  327. return { bednetid: Number(item.bednetid) };
  328. });
  329. AuditBedNet({ list, type: 0 }).then(() => {
  330. ElMessage.success("撤审成功!");
  331. vxeTableRef.value.refresh();
  332. });
  333. })
  334. .catch((e: TypeError) => {
  335. ElMessage({
  336. type: "info",
  337. message: "操作取消"
  338. });
  339. });
  340. }
  341. })
  342. ],
  343. buttonDefault({
  344. label: t("common.copyQuote"),
  345. power: 75,
  346. clickFunc: item => {
  347. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  348. if (!curRecords.length) {
  349. ElMessage.warning(t("business.tips.mattress.records"));
  350. return;
  351. }
  352. const _cur = $table.getCurrentRecord() ?? null;
  353. if (_cur) {
  354. router.push(`/bednetQuote/copy?id=${_cur.bednetid}&code=${_cur.bednetcode}`);
  355. } else {
  356. const _cur = curRecords[curRecords.length - 1];
  357. router.push(`/bednetQuote/copy?id=${_cur.bednetid}&code=${_cur.bednetcode}`);
  358. }
  359. }
  360. }),
  361. // [
  362. // buttonDefault({
  363. // label: t("common.businessOrder"),
  364. // power: 94,
  365. // clickFunc: item => {
  366. // toAuditing({ xd_flag: 1 }, t("common.businessOrder"));
  367. // }
  368. // }),
  369. // buttonDefault({
  370. // label: t("common.businessOrderCancel"),
  371. // power: 95,
  372. // clickFunc: item => {
  373. // toAuditing({ xd_flag: 0 }, t("common.businessOrder"));
  374. // }
  375. // })
  376. // ],
  377. // [
  378. // buttonDefault({
  379. // label: t("common.auditFinance"),
  380. // power: 73,
  381. // clickFunc: item => {
  382. // toAuditing({ flag: 1 }, t("common.auditFinance"));
  383. // }
  384. // }),
  385. // buttonDefault({
  386. // label: t("common.withdrawAuditFinance"),
  387. // power: 74,
  388. // clickFunc: item => {
  389. // toAuditing({ flag: 0 }, t("common.withdrawAuditFinance"));
  390. // }
  391. // })
  392. // ],
  393. buttonDefault({
  394. label: t("common.copyFromMulitFlag"),
  395. power: 61,
  396. clickFunc: item => {
  397. router.push(`/bednetQuote/new?id=0`);
  398. }
  399. }),
  400. buttonDefault({
  401. label: t("common.recalculateFromNotFlag"),
  402. power: 61,
  403. clickFunc: item => {
  404. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  405. console.log("curRecords :>> ", curRecords);
  406. if (!curRecords.length) {
  407. ElMessage.warning(t("business.tips.mattress.records"));
  408. return;
  409. }
  410. let list = curRecords.map((item: any) => {
  411. return { mattressid: Number(item.mattressid) };
  412. });
  413. ElMessageBox.confirm(`是否确定要批重算${curRecords.length}张床垫报价单吗?`, "询问", {
  414. confirmButtonText: t("common.okText"),
  415. cancelButtonText: "否",
  416. type: "warning"
  417. })
  418. .then(() => {
  419. ReCalculateBedNetNoAudit({ list }).then(() => {
  420. ElMessage.success("批重算成功!");
  421. vxeTableRef.value.refresh();
  422. });
  423. })
  424. .catch((e: TypeError) => {
  425. console.log("e :>> ", e);
  426. ElMessage({
  427. type: "info",
  428. message: "操作取消"
  429. });
  430. });
  431. }
  432. }),
  433. buttonDefault({
  434. label: t("common.viewHistoricalQuotes"),
  435. power: 61,
  436. clickFunc: item => {
  437. router.push(`/bednetQuote/new?id=0`);
  438. }
  439. }),
  440. buttonDefault({
  441. label: t("common.showQuoteList"),
  442. power: 61,
  443. clickFunc: item => {
  444. router.push(`/bednetQuote/new?id=0`);
  445. }
  446. }),
  447. buttonDefault({
  448. label: t("common.dataTransmission"),
  449. power: 61,
  450. clickFunc: item => {
  451. router.push(`/bednetQuote/new?id=0`);
  452. }
  453. })
  454. ];
  455. </script>