index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <div class="table-box">
  3. <LjVxeTable
  4. ref="vxeTableRef"
  5. row-key="mattressid"
  6. :columns="columns"
  7. :init-param="initParams"
  8. :request-api="getData"
  9. :data-callback="dataCallback"
  10. :dwname="DwnameEnum.mattressInterface"
  11. :table-props="tableProps"
  12. :table-events="tableEvents"
  13. :auto-load-layout="false"
  14. :search-btn-size-extent="[]"
  15. pagination
  16. :page-change-call-back="autoUpdateTableCheckbox"
  17. >
  18. <!-- 表格 header 按钮 -->
  19. <template #tableHeader>
  20. <LjHeaderMenu :update="dialogVisible" :action="action" />
  21. </template>
  22. </LjVxeTable>
  23. </div>
  24. </template>
  25. <script setup lang="ts" name="mattressQuote">
  26. import { ref, onMounted, inject } from "vue";
  27. import { useRouter } from "vue-router";
  28. import { MattressYWAudit, MattressJSAudit, MattressJS2Audit } from "@/api/modules/quote";
  29. import { CommonDynamicSelect } from "@/api/modules/common";
  30. import { ColumnProps } from "@/components/LjVxeTable/interface";
  31. import LjDrawer from "@/components/LjDrawer/index.vue";
  32. import { useHooks } from "./hooks/index";
  33. import LjDialog from "@/components/LjDialog/index.vue";
  34. import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
  35. import { useI18n } from "vue-i18n";
  36. import { useAuthButtons } from "@/hooks/useAuthButtons";
  37. import { DwnameEnum } from "@/enums/dwnameEnum";
  38. import { formatToDateTime, formatToDate } from "@/utils/dateUtil";
  39. import { cloneDeep } from "lodash-es";
  40. import { useGlobalStore } from "@/stores/modules/global";
  41. import { ElMessage, ElMessageBox, ElNotification } from "element-plus";
  42. import { detailAction } from "@/components/LjDetail/interface";
  43. import mittBus from "@/utils/mittBus";
  44. import { MittEnum } from "@/enums/mittEnum";
  45. import { getCurrentRecords } from "@/utils/index";
  46. import { usePageRouter } from "@/hooks/usePageRouter";
  47. const { t } = useI18n();
  48. const router = useRouter();
  49. const globalStore = useGlobalStore();
  50. const { initParams, columns, toCreateMtrl, toCreateORDelMtrlPf, YWAudit, JSAudit, JS2Audit } = useHooks(t);
  51. // const { toExcelQuote } = useHooksCpQuote();
  52. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  53. const { pageOpen } = usePageRouter();
  54. const dialogVisible = ref(false);
  55. const vxeTableRef = ref();
  56. const enumMap = ref(new Map());
  57. const getData = (params: any) => {
  58. console.log("getData mattress params :>> ", params);
  59. let newParams: any = {};
  60. params.pageNum && (newParams.pageindex = params.pageNum);
  61. params.pageSize && (newParams.pagesize = params.pageSize);
  62. params.orderstr && (newParams.orderstr = params.orderstr);
  63. delete params.pageNum;
  64. delete params.pageSize;
  65. delete params.orderstr;
  66. let _params = cloneDeep(params);
  67. newParams.queryParams = _params;
  68. newParams.dsname = "web_mattress_interfacelist";
  69. return CommonDynamicSelect(newParams, DwnameEnum.mattressInterface);
  70. };
  71. const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  72. if (globalStore.detailBlank) {
  73. // 打开新的窗口
  74. const routeUrl = router.resolve({
  75. path: `/erpapi/mattressInterface/detail`,
  76. query: {
  77. id: row.mattressid,
  78. code: row.mattresscode
  79. }
  80. });
  81. window.open(routeUrl.href, "_blank");
  82. } else {
  83. // 打开新的标签页
  84. // router.push(`/erpapi/mattressInterface/detail?id=${row.mattressid}&code=${row.mattresscode}`);
  85. router.push({
  86. path: `/erpapi/mattressInterface/detail/${row.mattressid}`,
  87. query: {
  88. code: row.mattresscode
  89. }
  90. });
  91. }
  92. };
  93. const rowClsNameFunc = (data: any) => {
  94. const { row, rowIndex, $rowIndex } = data;
  95. if (Number(row.creatmtrlqd_flag) != 1) {
  96. if (Number(row.creatmtrl_flag) == 0) {
  97. return "vxecol-danger";
  98. } else {
  99. return "vxecol-blue";
  100. }
  101. }
  102. return "";
  103. };
  104. const tableProps = {
  105. height: "auto",
  106. editConfig: { trigger: "click", mode: "cell" },
  107. rowClassName: rowClsNameFunc,
  108. treeConfig: {
  109. expandAll: true,
  110. transform: true,
  111. rowField: "mattressid",
  112. parentField: "parentid"
  113. },
  114. checkboxConfig: {
  115. showHeader: true,
  116. checkStrictly: true
  117. },
  118. exportConfig: {
  119. filename: t("menu.rpMsttake") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  120. }
  121. };
  122. // 返回绑定的事件
  123. const tableEvents = {
  124. // "checkbox-change": handleCheckboxChange,
  125. // "checkbox-all": handleCheckboxChange,
  126. // "checkbox-range-change": handleCheckboxChange,
  127. // "current-change": handleCurrentChanged
  128. "cell-dblclick": handleDBlClickTable
  129. // "cell-click": handleClickTable
  130. };
  131. /**
  132. * @description 按钮展示
  133. */
  134. const action: detailAction[] = [
  135. buttonDefault({
  136. label: t("common.redo"),
  137. clickFunc: item => {
  138. vxeTableRef.value.refresh();
  139. }
  140. }),
  141. buttonDefault({
  142. label: t("common.view"),
  143. clickFunc: item => {
  144. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  145. // vxeTableRef.value.refresh();
  146. handleDBlClickTable({ row: curRecords[0] });
  147. }
  148. }),
  149. // [
  150. // buttonDefault({
  151. // label: "业务补充",
  152. // power: 79,
  153. // clickFunc: item => {
  154. // routeToEdit(1);
  155. // }
  156. // }),
  157. // buttonDefault({
  158. // label: "业务审核",
  159. // power: 80,
  160. // clickFunc: item => {
  161. // const { curRecords } = getCurrentRecords(vxeTableRef.value);
  162. // YWAudit(1, curRecords, () => {
  163. // vxeTableRef.value.refresh();
  164. // });
  165. // }
  166. // }),
  167. // buttonDefault({
  168. // label: "业务撤审",
  169. // power: 81,
  170. // clickFunc: item => {
  171. // const { curRecords } = getCurrentRecords(vxeTableRef.value);
  172. // YWAudit(0, curRecords, () => {
  173. // vxeTableRef.value.refresh();
  174. // });
  175. // }
  176. // }),
  177. // ],
  178. // [
  179. buttonDefault({
  180. label: "产品补充",
  181. power: 82,
  182. clickFunc: item => {
  183. routeToEdit(2);
  184. }
  185. }),
  186. buttonDefault({
  187. label: "产品补充审核",
  188. power: 83,
  189. clickFunc: item => {
  190. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  191. JSAudit(1, curRecords, () => {
  192. vxeTableRef.value.refresh();
  193. });
  194. }
  195. }),
  196. buttonDefault({
  197. label: "产品补充撤审",
  198. power: 84,
  199. clickFunc: item => {
  200. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  201. JSAudit(0, curRecords, () => {
  202. ElNotification({
  203. title: t("sys.api.operationSuccess"),
  204. message: "产品补充审核后,需重新生成L1物料",
  205. type: "warning"
  206. });
  207. vxeTableRef.value.refresh();
  208. });
  209. }
  210. }),
  211. // ],
  212. // [
  213. buttonDefault({
  214. label: "清单补充",
  215. power: 85,
  216. clickFunc: item => {
  217. routeToEdit(3);
  218. }
  219. }),
  220. buttonDefault({
  221. label: "清单补充审核",
  222. power: 86,
  223. clickFunc: item => {
  224. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  225. JS2Audit(1, curRecords, () => {
  226. vxeTableRef.value.refresh();
  227. });
  228. }
  229. }),
  230. buttonDefault({
  231. label: "清单补充撤审",
  232. power: 87,
  233. clickFunc: item => {
  234. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  235. JS2Audit(0, curRecords, () => {
  236. vxeTableRef.value.refresh();
  237. });
  238. }
  239. }),
  240. // ],
  241. // [
  242. buttonDefault({
  243. label: "生成/更新物料",
  244. power: 88,
  245. clickFunc: item => {
  246. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  247. if (!curRecords.length) {
  248. ElMessage.warning(t("business.tips.mattress.records"));
  249. return;
  250. }
  251. let list = curRecords.map(item => item.mattressid);
  252. toCreateMtrl(1, list);
  253. }
  254. }),
  255. // ],
  256. // [
  257. buttonDefault({
  258. label: "生成金蝶清单",
  259. power: 90,
  260. clickFunc: item => {
  261. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  262. if (!curRecords.length) {
  263. ElMessage.warning(t("business.tips.mattress.records"));
  264. return;
  265. }
  266. let list = curRecords.map(item => item.mattressid);
  267. toCreateORDelMtrlPf(1, list);
  268. }
  269. })
  270. // buttonDefault({
  271. // label: "删除金蝶清单",
  272. // power: 91,
  273. // clickFunc: item => {
  274. // const { curRecords } = getCurrentRecords(vxeTableRef.value);
  275. // if (!curRecords.length) {
  276. // ElMessage.warning(t("business.tips.mattress.records"));
  277. // return;
  278. // }
  279. // toCreateORDelMtrlPf(0, curRecords[curRecords.length - 1].mattressid);
  280. // }
  281. // })
  282. // ]
  283. ];
  284. const dataCallback = (data: any) => {
  285. if (data.tableinfo?.columns) {
  286. data.tableinfo?.columns.map((item: any) => {
  287. if (item?.enum) {
  288. enumMap.value.set(item.field, item.enum);
  289. }
  290. });
  291. }
  292. return {
  293. list: data.datatable,
  294. tableinfo: data.tableinfo,
  295. total: data.totalcnt,
  296. pageNum: data.pageindex,
  297. pageSize: data.pagesize
  298. };
  299. };
  300. const routeToEdit = async type => {
  301. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  302. if (!curRecords.length) {
  303. ElMessage.warning(t("business.tips.mattress.records"));
  304. return;
  305. }
  306. const _cur = curRecords[curRecords.length - 1];
  307. // router.push(`/erpapi/mattressInterface/${type}/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}&type=${type}`);
  308. try {
  309. if (type === 1) {
  310. if (_cur.yw_flag == 1) {
  311. throw new Error(_cur.mattresscode + ":已业务补充审核,无法修改");
  312. }
  313. } else if (type === 2) {
  314. if (_cur.js1_flag == 1) {
  315. throw new Error(_cur.mattresscode + ":已产品补充审核,无法修改");
  316. }
  317. } else if (type === 3) {
  318. if (_cur.js2_flag == 1) {
  319. throw new Error(_cur.mattresscode + ":已清单补充审核,无法修改");
  320. }
  321. }
  322. } catch (error) {
  323. ElMessage.error(error.message);
  324. return false;
  325. }
  326. pageOpen({
  327. name: "mattressInterfaceEditYw",
  328. params: {
  329. id: _cur.mattressid,
  330. code: _cur.mattresscode
  331. },
  332. query: {
  333. code: _cur.mattresscode,
  334. type: type
  335. }
  336. });
  337. // router.push({
  338. // path: `/erpapi/mattressInterface/edit/${_cur.mattressid}`,
  339. // query: {
  340. // id: _cur.mattressid,
  341. // code: _cur.mattresscode,
  342. // type: type
  343. // }
  344. // });
  345. };
  346. /**
  347. * @description 监听框架属性变化
  348. */
  349. mittBus.on(MittEnum.MattressList, () => {
  350. vxeTableRef.value.refresh();
  351. });
  352. const autoUpdateTableCheckbox = () => {
  353. const $table = vxeTableRef.value.element;
  354. if ($table) {
  355. $table.setAllTreeExpand(true);
  356. }
  357. };
  358. </script>