detail.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <LjDetail
  3. name="mattressInterfaceDetail"
  4. ref="LjDetailRef"
  5. v-bind="detailProps"
  6. :data="[mainData]"
  7. v-model:order-status="orderStatus"
  8. :action="orderDefaultAction"
  9. @after-mounted="funcAfterMound"
  10. :if-layout-editable="false"
  11. :search-col="{ xs: 3, sm: 3, md: 3, lg: 3, xl: 3 }"
  12. :basic-group-col="{ xs: 3, sm: 3, md: 3, lg: 3, xl: 3 }"
  13. >
  14. <template #mattressYW>
  15. <LjVxeTable
  16. ref="VxeTableMxRef"
  17. row-key="key"
  18. table-cls=""
  19. :data="mattressYWList"
  20. :columns="columns_yw"
  21. :dwname="DwnameEnum.mattressInterfaceYw"
  22. :request-auto="false"
  23. :table-props="tableProps_mx"
  24. :tool-button="[]"
  25. :auto-load-layout="false"
  26. collapseButtons
  27. >
  28. </LjVxeTable>
  29. </template>
  30. <template #mattressQD>
  31. <el-row class="h-full" :gutter="10">
  32. <el-col :span="6">
  33. <LjVxeTable
  34. ref="YwTableRef"
  35. row-key="key"
  36. table-cls="h-full"
  37. :data="mattressYWList"
  38. :columns="columns_yw_qd"
  39. :dwname="DwnameEnum.mattressInterfaceYw"
  40. :request-auto="false"
  41. :table-props="tableProps_mx"
  42. :tool-button="[]"
  43. :auto-load-layout="false"
  44. collapseButtons
  45. >
  46. </LjVxeTable>
  47. </el-col>
  48. <el-col :span="18">
  49. <LjVxeTable
  50. ref="QdTableRef"
  51. row-key="key"
  52. table-cls="h-full"
  53. :data="mattressQDList"
  54. :columns="columns_qd"
  55. :dwname="DwnameEnum.mattressInterfaceQd"
  56. :request-auto="false"
  57. :table-props="tableProps_mx"
  58. :tool-button="[]"
  59. :auto-load-layout="false"
  60. collapseButtons
  61. >
  62. </LjVxeTable>
  63. </el-col>
  64. </el-row>
  65. </template>
  66. </LjDetail>
  67. <MattressDialog ref="MattressDialogRef" v-bind="MattressDialogProps" />
  68. <MtrldefErpDialog ref="MtrldefErpDialogRef" v-bind="MtrldefErpDialogProps" />
  69. </template>
  70. <script setup lang="tsx" name="mattressInterfaceDetail">
  71. import { ref, watch, reactive, inject, onMounted } from "vue";
  72. import { DwnameEnum } from "@/enums/dwnameEnum";
  73. import LjDetail from "@/components/LjDetail/index.vue";
  74. import { DetailProp } from "@/components/LjDetail/interface";
  75. import { useI18n } from "vue-i18n";
  76. import { useRoute, useRouter } from "vue-router";
  77. import { useHooks } from "./hooks/index";
  78. import { useAuthButtons } from "@/hooks/useAuthButtons";
  79. import { CommonDynamicSelect, GetERPWrkGrpList } from "@/api/modules/common";
  80. import { SaveMattressInterface } from "@/api/modules/quote";
  81. import { ElMessage, ElMessageBox, ElNotification } from "element-plus";
  82. import mittBus from "@/utils/mittBus";
  83. import { MittEnum } from "@/enums/mittEnum";
  84. import MattressDialog from "@/views/system/selector/mattress/index.vue";
  85. import MtrldefErpDialog from "@/views/system/selector/mtrldefErp/index.vue";
  86. import { formatToDate } from "@/utils/dateUtil";
  87. interface detailProp {
  88. /**
  89. * @argument any 页面数据
  90. */
  91. data?: any;
  92. /**
  93. * @argument string 请求数据的api ==> 非必传
  94. */
  95. requestApi?: (params: any) => Promise<any>;
  96. /**
  97. * @argument any 基础信息,表格展示数据
  98. */
  99. // columns?: any;
  100. /**
  101. * @description 是否可编辑
  102. */
  103. status: "edit" | "new" | string;
  104. enum?: any;
  105. }
  106. const props = withDefaults(defineProps<detailProp>(), {});
  107. const { t } = useI18n();
  108. const route = useRoute();
  109. const router = useRouter();
  110. const {
  111. VxeTableMxRef,
  112. YwTableRef,
  113. QdTableRef,
  114. orderStatus,
  115. LjDetailRef,
  116. columns_detail,
  117. columns_yw,
  118. columns_yw_qd,
  119. columns_qd,
  120. mainData,
  121. editType,
  122. mattressYWList,
  123. mattressQDList,
  124. MattressDialogRef,
  125. MattressDialogProps,
  126. MtrldefErpDialogRef,
  127. MtrldefErpDialogProps,
  128. tableProps_mx,
  129. workgrpEnum,
  130. configureTypeEnum,
  131. RetriveMattressInterface,
  132. RefreshMattressInterfaceList,
  133. RefreshMattressInterfaceQdList,
  134. fModelChoseMattress,
  135. toExcel,
  136. toCreateORDelMtrlPf
  137. } = useHooks(t);
  138. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  139. const initParams = ref({ mattressid: 0 as Number });
  140. const detailProps = reactive<DetailProp>({
  141. dwname: DwnameEnum.mattressInterfaceDetail,
  142. columns: columns_detail,
  143. basicDefault: {},
  144. header: {
  145. foldright: {
  146. width: 80
  147. },
  148. fieldNames: {
  149. code: "sptcode",
  150. codeLabel: t("table.u_spt.sptcode") + ":",
  151. name: "name"
  152. }
  153. },
  154. mould: [
  155. {
  156. id: "mattressYW",
  157. type: "table",
  158. label: "产品配置"
  159. },
  160. {
  161. id: "mattressQD",
  162. type: "table",
  163. label: "产品清单"
  164. }
  165. ]
  166. });
  167. const tabRemove: Function = inject("tabRemove") as Function;
  168. const loadingStatus = reactive({
  169. save: false
  170. });
  171. const orderDefaultAction = [
  172. buttonDefault({
  173. label: t("common.cancelText"),
  174. icon: "iconchevron-left",
  175. limited: () => {
  176. return !orderStatus.value;
  177. },
  178. clickFunc: item => {
  179. router.replace(`/erpapi/mattressInterface/detail?id=${mainData.value.mattressid}&code=${mainData.value.mattresscode}`);
  180. }
  181. }),
  182. buttonDefault({
  183. label: t("common.saveText"),
  184. loading: () => loadingStatus.save,
  185. limited: () => !orderStatus.value,
  186. clickFunc: item => {
  187. ElMessageBox.confirm("是否确定要保存吗?", "询问", {
  188. confirmButtonText: "是",
  189. cancelButtonText: "否",
  190. type: "warning"
  191. }).then(async () => {
  192. try {
  193. const res = await SaveMattressInterface({
  194. mattress: mainData.value,
  195. interfaceList: mattressYWList.value,
  196. qdList: mattressQDList.value
  197. })
  198. .then(res => {
  199. ElNotification({
  200. title: "温馨提示",
  201. message: t("sys.api.sueccessToSave"),
  202. type: "success"
  203. });
  204. tabRemove(route.fullPath);
  205. router.push(`/erpapi/mattressInterface/detail?id=${mainData.value.mattressid}&code=${mainData.value.mattresscode}`);
  206. loadingStatus.save = false;
  207. })
  208. .catch(error => {
  209. console.log("error !! :>> ", error);
  210. loadingStatus.save = false;
  211. });
  212. } catch (error) {
  213. ElMessage.error(t("sys.api.operationFailed"));
  214. }
  215. });
  216. }
  217. }),
  218. [
  219. buttonDefault({
  220. label: "刷新带出配置",
  221. limited: () => {
  222. return !orderStatus.value || editType.value == 3;
  223. },
  224. clickFunc: item => {
  225. RefreshMattressInterfaceList(mainData.value.mattressid, 1);
  226. }
  227. }),
  228. buttonDefault({
  229. label: "复制配置",
  230. limited: () => {
  231. return !orderStatus.value || editType.value == 3;
  232. },
  233. clickFunc: item => {
  234. fModelChoseMattress().then((res: any) => {
  235. RefreshMattressInterfaceList(res.mattressid, 1);
  236. });
  237. }
  238. }),
  239. buttonDefault({
  240. label: "重新生成配置项目",
  241. limited: () => {
  242. return !orderStatus.value || editType.value != 1;
  243. },
  244. clickFunc: item => {
  245. RefreshMattressInterfaceList(mainData.value.mattressid, 0);
  246. }
  247. })
  248. ],
  249. [
  250. buttonDefault({
  251. label: "刷新清单",
  252. limited: () => {
  253. return !orderStatus.value;
  254. },
  255. clickFunc: item => {
  256. RefreshMattressInterfaceQdList(mainData.value.mattressid, 1);
  257. }
  258. }),
  259. buttonDefault({
  260. label: "复制清单",
  261. limited: () => {
  262. return !orderStatus.value;
  263. },
  264. clickFunc: item => {
  265. fModelChoseMattress().then((res: any) => {
  266. RefreshMattressInterfaceQdList(res.mattressid, 1, 0);
  267. });
  268. }
  269. }),
  270. buttonDefault({
  271. label: "重新生成清单",
  272. limited: () => {
  273. return !orderStatus.value;
  274. },
  275. clickFunc: item => {
  276. RefreshMattressInterfaceQdList(mainData.value.mattressid, 0);
  277. }
  278. })
  279. ],
  280. [
  281. buttonDefault({
  282. label: "生成金蝶清单",
  283. power: 90,
  284. clickFunc: item => {
  285. toCreateORDelMtrlPf(1, mainData.value.mattressid);
  286. }
  287. }),
  288. buttonDefault({
  289. label: "删除金蝶清单",
  290. power: 91,
  291. clickFunc: item => {
  292. toCreateORDelMtrlPf(0, mainData.value.mattressid);
  293. }
  294. })
  295. ],
  296. buttonDefault({
  297. label: t("common.back"),
  298. clickFunc: item => {
  299. router.push(`/erpapi/mattressInterface`);
  300. }
  301. })
  302. ];
  303. /**
  304. * @description 页面数据加载完成
  305. */
  306. const funcAfterMound = async () => {
  307. console.log("onMounted detail sale start!!!! :>> ");
  308. if (!orderStatus.value) {
  309. // 详情页
  310. // gotoSummy(8000);
  311. } else {
  312. // 新增/编辑
  313. tableProps_mx.value.editConfig.enabled = true;
  314. // tableProps_mx_yw.value.editConfig.enabled = true;
  315. // tableProps_mx_qd.value.editConfig.enabled = true;
  316. }
  317. console.log("onMounted detail sale start LjDetailRef.value.mainData :>> ", LjDetailRef.value);
  318. if (orderStatus.value != "new") {
  319. }
  320. };
  321. onMounted(async () => {
  322. console.log("route onMounted:>> ", route);
  323. console.log("route onMounted:>> ", route.params);
  324. console.log("route onMounted:>> ", route.params.id);
  325. const result = await GetERPWrkGrpList();
  326. if (result.workgroupList) {
  327. workgrpEnum.value = result.workgroupList.map(item => {
  328. return {
  329. label: item.wrkgrpname,
  330. value: item.wrkgrpid
  331. };
  332. });
  333. columns_qd.value = columns_qd.value.map(item => {
  334. if (item.field == "wrkgrpid") {
  335. item.editRender.options = workgrpEnum.value;
  336. }
  337. return item;
  338. });
  339. }
  340. if (route.query?.id) {
  341. // 刷新数据
  342. initParams.value.mattressid = Number(route.query?.id);
  343. editType.value = Number(route.query?.type);
  344. console.log("detail onMounted initParams.value :>> ", initParams.value);
  345. console.log("领用工组领用工组领用工组领用工组 columns_qd.value :>> ", columns_qd.value);
  346. await RetriveMattressInterface(initParams.value.mattressid.valueOf());
  347. }
  348. });
  349. </script>