index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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="dataCallbackMx"
  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="mattressQuote">
  81. import { ref, onMounted, inject } from "vue";
  82. import { useRouter } from "vue-router";
  83. import { SaveMattressAuditing, DelMattress } 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. dataCallbackMx
  118. } = useHooks();
  119. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  120. const dialogVisible = ref(false);
  121. const vxeTableRef = ref();
  122. const vxeTableMxRef = ref();
  123. const vxeTableMxSpringRef = ref();
  124. const LjFoldLayoutRef = ref();
  125. const layoutSetting = {
  126. dwname: DwnameEnum.bednetQuote,
  127. direction: "vertical",
  128. right: {
  129. // hidden: true
  130. }
  131. };
  132. const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  133. if (globalStore.detailBlank) {
  134. // 打开新的窗口
  135. const routeUrl = router.resolve({
  136. path: `/bednetQuote/detail`,
  137. query: {
  138. id: row.bednetid,
  139. code: row.bednetcode
  140. }
  141. });
  142. window.open(routeUrl.href, "_blank");
  143. } else {
  144. // if (currentLayout.value.right.hidden && globalStore.mxFloat?.includes("custCrmDetail")) {
  145. // // 弹窗
  146. // mainData.value = row;
  147. // LjDrawerRef.value.show();
  148. // } else {
  149. // 打开新的标签页
  150. router.push(`/bednetQuote/detail?id=${row.bednetid}&code=${row.bednetcode}`);
  151. // }
  152. }
  153. };
  154. const handleClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  155. initParamsMx.value.arg_bednetid = row.bednetid;
  156. };
  157. const rowClsNameFunc = (data: any) => {
  158. const { row, rowIndex, $rowIndex } = data;
  159. if (row.flag == "0") {
  160. return "vxecol-danger";
  161. }
  162. return "";
  163. };
  164. const tableProps = {
  165. height: "auto",
  166. editConfig: { trigger: "click", mode: "cell" },
  167. rowClassName: rowClsNameFunc
  168. // exportConfig: {
  169. // filename: t("menu.saletaskmx") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  170. // }
  171. };
  172. const autoMonthedData = (data: any) => {
  173. const $table = vxeTableRef.value.element;
  174. console.log("autoMonthedData 123:>> ", $table);
  175. if ($table) {
  176. let { fullData } = $table.getTableData();
  177. console.log("object :>> ", $table.getTableData());
  178. if (fullData.length > 0) {
  179. $table.setCurrentRow(fullData[0]);
  180. initParamsMx.value.arg_bednetid = fullData[0].bednetid;
  181. }
  182. }
  183. };
  184. const handleClickTableMx = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  185. initParamsMxSpring.value.arg_bednetmxid = row.bednetmxid;
  186. };
  187. // 返回绑定的事件
  188. const tableEvents = {
  189. "cell-dblclick": handleDBlClickTable,
  190. "cell-click": handleClickTable
  191. };
  192. // 返回绑定的事件
  193. const tableEventsMx = {
  194. "cell-click": handleClickTableMx
  195. };
  196. /**
  197. * @description 按钮展示
  198. */
  199. const action: detailAction[] = [
  200. buttonDefault({
  201. label: t("common.redo"),
  202. clickFunc: item => {
  203. vxeTableRef.value.refresh();
  204. }
  205. }),
  206. buttonDefault({
  207. label: t("common.add"),
  208. power: 62,
  209. clickFunc: item => {
  210. console.log("inewss nitParams.value :>> ", vxeTableRef.value.searchParam);
  211. let _deptid = 0;
  212. if (Object.keys(vxeTableRef.value.searchParam).includes("arg_deptid")) {
  213. _deptid = vxeTableRef.value.searchParam.arg_deptid;
  214. }
  215. router.push(`/mattressQuote/new?id=0&deptid=${_deptid}`);
  216. }
  217. }),
  218. buttonDefault({
  219. label: t("common.editText"),
  220. power: 62,
  221. clickFunc: item => {
  222. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  223. if (!curRecords.length) {
  224. ElMessage.warning(t("business.tips.mattress.records"));
  225. return;
  226. }
  227. const _cur = $table.getCurrentRecord() ?? null;
  228. if (_cur) {
  229. router.push(`/mattressQuote/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}`);
  230. } else {
  231. const _cur = curRecords[curRecords.length - 1];
  232. router.push(`/mattressQuote/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}`);
  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. // let _mattressids = curRecords.map((item: any) => Number(item.mattressid));
  253. // ElMessageBox.confirm(`是否确定要删除${curRecords.length}张床垫报价单吗?`, "询问", {
  254. // confirmButtonText: t("common.delText"),
  255. // cancelButtonText: "否",
  256. // type: "warning"
  257. // })
  258. // .then(() => {
  259. // DelMattress({ mattressids: _mattressids }).then(() => {
  260. // ElMessage.success("删除成功!");
  261. // vxeTableRef.value.refresh();
  262. // });
  263. // })
  264. // .catch((e: TypeError) => {
  265. // console.log("e :>> ", e);
  266. // ElMessage({
  267. // type: "info",
  268. // message: "操作取消"
  269. // });
  270. // });
  271. }
  272. }),
  273. [
  274. buttonDefault({
  275. label: t("common.auditFinance"),
  276. power: 63,
  277. disabledTextCallBack: (data: any) => {
  278. if (!CheckPower(63)) {
  279. return `你没有【报价单-${t("common.auditFinance")}】的使用权限`;
  280. }
  281. return "";
  282. },
  283. clickFunc: item => {
  284. // ElMessageBox.confirm(`是否确定要${t("common.auditFinance")}吗?`, "询问", {
  285. // confirmButtonText: "是",
  286. // cancelButtonText: "否",
  287. // type: "warning"
  288. // })
  289. // .then(() => {
  290. // let _params = {
  291. // mattressids: [Number(LjDetailRef.value._mainData.mattressid)],
  292. // flag: 1
  293. // };
  294. // SaveMattressAuditing(_params).then(() => {
  295. // ElMessage.success(t("sys.api.operationSuccess"));
  296. // LjDetailRef.value.refresh();
  297. // });
  298. // })
  299. // .catch((e: TypeError) => {
  300. // ElMessage({
  301. // type: "info",
  302. // message: "操作取消"
  303. // });
  304. // });
  305. }
  306. }),
  307. buttonDefault({
  308. label: t("common.withdrawAuditFinance"),
  309. power: 64,
  310. disabledTextCallBack: (data: any) => {
  311. if (!CheckPower(64)) {
  312. return `你没有【报价单-${t("common.withdrawAuditFinance")}】的使用权限`;
  313. }
  314. return "";
  315. },
  316. clickFunc: item => {
  317. // ElMessageBox.confirm(`是否确定要${t("common.withdrawAuditFinance")}吗?`, "询问", {
  318. // confirmButtonText: "是",
  319. // cancelButtonText: "否",
  320. // type: "warning"
  321. // })
  322. // .then(() => {
  323. // let _params = {
  324. // mattressids: [Number(LjDetailRef.value._mainData.mattressid)],
  325. // flag: 0
  326. // };
  327. // SaveMattressAuditing(_params).then(() => {
  328. // ElMessage.success(t("sys.api.operationSuccess"));
  329. // LjDetailRef.value.refresh();
  330. // });
  331. // })
  332. // .catch((e: TypeError) => {
  333. // ElMessage({
  334. // type: "info",
  335. // message: "操作取消"
  336. // });
  337. // });
  338. }
  339. })
  340. ],
  341. buttonDefault({
  342. label: t("common.copyQuote"),
  343. clickFunc: item => {
  344. router.push(`/mattressQuote/new?id=0`);
  345. }
  346. }),
  347. // [
  348. // buttonDefault({
  349. // label: t("common.businessOrder"),
  350. // power: 94,
  351. // clickFunc: item => {
  352. // toAuditing({ xd_flag: 1 }, t("common.businessOrder"));
  353. // }
  354. // }),
  355. // buttonDefault({
  356. // label: t("common.businessOrderCancel"),
  357. // power: 95,
  358. // clickFunc: item => {
  359. // toAuditing({ xd_flag: 0 }, t("common.businessOrder"));
  360. // }
  361. // })
  362. // ],
  363. // [
  364. // buttonDefault({
  365. // label: t("common.auditFinance"),
  366. // power: 73,
  367. // clickFunc: item => {
  368. // toAuditing({ flag: 1 }, t("common.auditFinance"));
  369. // }
  370. // }),
  371. // buttonDefault({
  372. // label: t("common.withdrawAuditFinance"),
  373. // power: 74,
  374. // clickFunc: item => {
  375. // toAuditing({ flag: 0 }, t("common.withdrawAuditFinance"));
  376. // }
  377. // })
  378. // ],
  379. buttonDefault({
  380. label: t("common.copyFromMulitFlag"),
  381. power: 61,
  382. clickFunc: item => {
  383. router.push(`/mattressQuote/new?id=0`);
  384. }
  385. }),
  386. buttonDefault({
  387. label: t("common.recalculateFromNotFlag"),
  388. power: 61,
  389. clickFunc: item => {
  390. router.push(`/mattressQuote/new?id=0`);
  391. }
  392. }),
  393. buttonDefault({
  394. label: t("common.viewHistoricalQuotes"),
  395. power: 61,
  396. clickFunc: item => {
  397. router.push(`/mattressQuote/new?id=0`);
  398. }
  399. }),
  400. buttonDefault({
  401. label: t("common.showQuoteList"),
  402. power: 61,
  403. clickFunc: item => {
  404. router.push(`/mattressQuote/new?id=0`);
  405. }
  406. }),
  407. buttonDefault({
  408. label: t("common.dataTransmission"),
  409. power: 61,
  410. clickFunc: item => {
  411. router.push(`/mattressQuote/new?id=0`);
  412. }
  413. })
  414. ];
  415. </script>