detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <LjDetail
  3. name="softbedQuoteDetail"
  4. ref="LjDetailRef"
  5. v-bind="detailProps"
  6. :data="softBed"
  7. :dwname="DwnameEnum.softbedQuote"
  8. v-model:order-status="orderStatus"
  9. :action="orderDefaultAction"
  10. @after-mounted="funcAfterMound"
  11. :if-layout-editable="false"
  12. :request-auto="false"
  13. :auto-load-layout="true"
  14. >
  15. <template #HeadBoard>
  16. <LjVxeTable
  17. ref="VxeTableHeadBoardMxRef"
  18. row-key="key"
  19. table-cls="h-full"
  20. :data="headBoardMx"
  21. :columns="columnsMx"
  22. :dwname="DwnameEnum.softbedQuoteMx"
  23. :table-props="tableProps_mx"
  24. :tool-button="[]"
  25. :auto-load-layout="false"
  26. :request-auto="false"
  27. >
  28. <template #tableHeader>
  29. <el-space wrap v-if="orderStatus">
  30. <el-button type="primary" @click="toAddMx(VxeTableHeadBoardMxRef)">{{ t("common.addText") }}</el-button>
  31. <el-button type="danger" @click="toDelMx(VxeTableHeadBoardMxRef)">{{ t("common.delText") }}</el-button>
  32. </el-space>
  33. </template>
  34. </LjVxeTable>
  35. </template>
  36. <template #NightStand>
  37. <LjVxeTable
  38. ref="VxeTableNightStandMxRef"
  39. row-key="key"
  40. table-cls="h-full"
  41. :data="nightStandMx"
  42. :columns="columnsMx"
  43. :dwname="DwnameEnum.softbedQuoteMx"
  44. :table-props="tableProps_mx"
  45. :tool-button="[]"
  46. :auto-load-layout="false"
  47. :request-auto="false"
  48. >
  49. <template #tableHeader>
  50. <el-space wrap v-if="orderStatus">
  51. <el-button type="primary" @click="toAddMx(VxeTableNightStandMxRef)">{{ t("common.addText") }}</el-button>
  52. <el-button type="danger" @click="toDelMx(VxeTableNightStandMxRef)">{{ t("common.delText") }}</el-button>
  53. </el-space>
  54. </template>
  55. </LjVxeTable>
  56. </template>
  57. <template #BedFrame>
  58. <LjVxeTable
  59. ref="VxeTableBedFrameMxRef"
  60. row-key="key"
  61. table-cls="h-full"
  62. :data="bedFrameMx"
  63. :columns="columnsMx"
  64. :dwname="DwnameEnum.softbedQuoteMx"
  65. :table-props="tableProps_mx"
  66. :tool-button="[]"
  67. :auto-load-layout="false"
  68. :request-auto="false"
  69. >
  70. <template #tableHeader>
  71. <el-space wrap v-if="orderStatus">
  72. <el-button type="primary" @click="toAddMx(VxeTableBedFrameMxRef)">{{ t("common.addText") }}</el-button>
  73. <el-button type="danger" @click="toDelMx(VxeTableBedFrameMxRef)">{{ t("common.delText") }}</el-button>
  74. </el-space>
  75. </template>
  76. </LjVxeTable>
  77. </template>
  78. <template #Other>
  79. <LjVxeTable
  80. ref="VxeTableOtherMxRef"
  81. row-key="key"
  82. table-cls="h-full"
  83. :data="otherMx"
  84. :columns="columnsMxOther"
  85. :dwname="DwnameEnum.softbedQuoteMx"
  86. :table-props="tableProps_mx"
  87. :tool-button="[]"
  88. :auto-load-layout="false"
  89. :request-auto="false"
  90. >
  91. <template #tableHeader>
  92. <el-space wrap v-if="orderStatus">
  93. <el-button type="primary" @click="toAddMx(VxeTableOtherMxRef)">{{ t("common.addText") }}</el-button>
  94. <el-button type="danger" @click="toDelMx(VxeTableOtherMxRef)">{{ t("common.delText") }}</el-button>
  95. </el-space>
  96. </template>
  97. </LjVxeTable>
  98. </template>
  99. </LjDetail>
  100. <BedConfigModal
  101. v-model="isModalVisible"
  102. v-model:showHeadboard="showHeadboard"
  103. v-model:showNightstand="showNightstand"
  104. v-model:showBedframe="showBedframe"
  105. v-model:partsConfig="partsConfig"
  106. :headboardConfigOptions="headboardConfigOptions"
  107. :nightstandConfigOptions="nightstandConfigOptions"
  108. :bedframeConfigOptions="bedframeConfigOptions"
  109. :configValueOptionsMap="configValueOptionsMap"
  110. @submit="onConfirmConfigureDialog"
  111. @cancel="isModalVisible = false"
  112. />
  113. <ErpMtrlPriceDialog ref="ErpMtrlPriceDialogRef" v-bind="ErpMtrlPriceDialogProps" />
  114. <SoftBedTemplateDialog ref="SoftBedTemplateDialogRef" v-bind="SoftBedTemplateDialogProps" />
  115. <!-- <FormulaEditorDialog ref="formulaEditorRef" @confirm="handleFormulaConfirm" /> -->
  116. <FormulaEditor ref="sharedFormulaEditorRef" @confirm="handleFormulaConfirm" />
  117. </template>
  118. <script setup lang="tsx" name="softBedQuoteDetail">
  119. import { ref, watch, reactive, inject, onMounted } from "vue";
  120. import { DwnameEnum } from "@/enums/dwnameEnum";
  121. import LjDetail from "@/components/LjDetail/index.vue";
  122. import { DetailProp } from "@/components/LjDetail/interface";
  123. import { useI18n } from "vue-i18n";
  124. import { useRoute, useRouter } from "vue-router";
  125. import { useAuthButtons } from "@/hooks/useAuthButtons";
  126. import { useHooks } from "./hooks/index";
  127. import { useUserStore } from "@/stores/modules/user";
  128. import BedConfigModal from "./components/BedConfigModal.vue";
  129. import ErpMtrlPriceDialog from "@/views/system/selector/erpMtrlPrice/index.vue";
  130. import SoftBedTemplateDialog from "@/views/system/selector/softbedTemplate/index.vue";
  131. import FormulaEditorDialog from "@/views/system/formula-editor/index.vue";
  132. import FormulaEditor from "@/views/system/formula-editor/index.vue";
  133. import { usePageRouter } from "@/hooks/usePageRouter";
  134. const { t } = useI18n();
  135. const route = useRoute();
  136. const router = useRouter();
  137. const {
  138. orderStatus,
  139. LjDetailRef,
  140. VxeTableHeadBoardMxRef,
  141. VxeTableNightStandMxRef,
  142. VxeTableBedFrameMxRef,
  143. formulaEditorRef,
  144. sharedFormulaEditorRef,
  145. columns,
  146. columnsMx,
  147. columnsMxOther,
  148. softBed,
  149. headBoardMx,
  150. nightStandMx,
  151. bedFrameMx,
  152. otherMx,
  153. VxeTableOtherMxRef,
  154. isModalVisible,
  155. showHeadboard,
  156. showBedframe,
  157. showNightstand,
  158. headboardConfigOptions,
  159. nightstandConfigOptions,
  160. bedframeConfigOptions,
  161. configValueOptionsMap,
  162. ErpMtrlPriceDialogProps,
  163. ErpMtrlPriceDialogRef,
  164. SoftBedTemplateDialogRef,
  165. SoftBedTemplateDialogProps,
  166. partsConfig,
  167. loadingStatus,
  168. detail_getData,
  169. toAddMx,
  170. toDelMx,
  171. onSave,
  172. onAudit,
  173. onCAudit,
  174. onDelete,
  175. onConfirmConfigureDialog,
  176. GetSoftBedFormulaMapper,
  177. GetSoftBedAccessoryMapper,
  178. openSharedFormulaEditor,
  179. handleFormulaConfirm
  180. } = useHooks(t);
  181. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  182. const { pageRefresh } = usePageRouter();
  183. const initParams = ref({ billid: 0 as Number });
  184. // const partsConfig = reactive({
  185. // headboard: [],
  186. // nightstand: [],
  187. // bedframe: []
  188. // });
  189. const tabRemove: Function = inject("tabRemove") as Function;
  190. const { userInfo } = useUserStore();
  191. /**
  192. * @description 明细表格组件基础配置
  193. */
  194. const tableProps = ref({
  195. height: "auto",
  196. align: "left",
  197. // height: "",
  198. minHeight: "300px",
  199. editConfig: { trigger: "click", mode: "cell", enabled: false },
  200. // exportConfig: {
  201. // filename: t("menu.saleTaskCrmDetail") + formatToDate(new Date(), "YYYY-MM-DDHH:mm:ss")
  202. // }
  203. keyboardConfig: {
  204. isEdit: true,
  205. isArrow: true,
  206. isEnter: true,
  207. isTab: true,
  208. isDel: true,
  209. isBack: true,
  210. isEsc: true,
  211. editMethod({ $table, row, column }) {
  212. // 先清空原先的值
  213. row[column.field] = "";
  214. // 再激活编辑状态并输入新值
  215. $table.setEditCell(row, column);
  216. }
  217. },
  218. mouseConfig: {
  219. selected: true
  220. }
  221. });
  222. /**
  223. * @description 明细表格组件基础配置
  224. */
  225. const tableProps_mx = ref({
  226. height: "auto",
  227. align: "left",
  228. // height: "",
  229. minHeight: "100px",
  230. editConfig: { trigger: "click", mode: "row", enabled: false, autoClear: false },
  231. keyboardConfig: {
  232. isEdit: true,
  233. isArrow: true,
  234. isEnter: true,
  235. isTab: true,
  236. isDel: true,
  237. isBack: true,
  238. isEsc: true,
  239. editMethod({ $table, row, column }) {
  240. // 先清空原先的值
  241. row[column.field] = "";
  242. // 再激活编辑状态并输入新值
  243. $table.setEditCell(row, column);
  244. }
  245. },
  246. mouseConfig: {
  247. selected: true
  248. },
  249. cellClick: (data: any) => {
  250. console.log(data);
  251. }
  252. });
  253. const detailProps = reactive<DetailProp>({
  254. dwname: DwnameEnum.softbedQuote,
  255. columns: columns,
  256. basicDefault: {},
  257. header: {
  258. fieldNames: {
  259. code: "softbed_code",
  260. codeLabel: "核价编码:",
  261. name: "name"
  262. }
  263. },
  264. mould: [
  265. {
  266. id: "HeadBoard",
  267. type: "table",
  268. label: "床头",
  269. limited: (params: any) => {
  270. if (!params) return true;
  271. return params?.has_headboard === 0;
  272. }
  273. },
  274. {
  275. id: "NightStand",
  276. type: "table",
  277. label: "床头柜",
  278. limited: (params: any) => {
  279. if (!params) return true;
  280. return params?.has_nightstand === 0;
  281. }
  282. },
  283. {
  284. id: "BedFrame",
  285. type: "table",
  286. label: "床架",
  287. limited: (params: any) => {
  288. if (!params) return true;
  289. return params?.has_bedframe === 0;
  290. }
  291. },
  292. {
  293. id: "Other",
  294. type: "table",
  295. label: "其他"
  296. }
  297. ]
  298. });
  299. const orderDefaultAction = [
  300. buttonDefault({
  301. label: t("common.cancelText"),
  302. icon: "iconchevron-left",
  303. limited: () => {
  304. return !orderStatus.value;
  305. },
  306. clickFunc: item => {
  307. // if (route.path.indexOf("/new") > -1) {
  308. // tabRemove(route.fullPath);
  309. // } else {
  310. // router.replace(
  311. // `/softbedQuote/detail?id=${LjDetailRef.value._mainData.softbed_id}&code=${LjDetailRef.value._mainData.softbed_code}`
  312. // );
  313. pageRefresh({
  314. name: "softbedQuoteDetail",
  315. params: {
  316. id: LjDetailRef.value._mainData.softbed_id,
  317. code: LjDetailRef.value._mainData.softbed_code
  318. },
  319. query: {
  320. id: LjDetailRef.value._mainData.softbed_id,
  321. code: LjDetailRef.value._mainData.softbed_code
  322. }
  323. });
  324. // }
  325. }
  326. }),
  327. buttonNew({
  328. label: t("common.saveText"),
  329. icon: "iconsave-01",
  330. loading: () => loadingStatus.value.save,
  331. limited: () => !orderStatus.value,
  332. disabledTextCallBack: data => {
  333. if (data.flag > 0) {
  334. return "单据已审核,无法保存!";
  335. }
  336. return "";
  337. },
  338. clickFunc: () => {
  339. onSave(res => {
  340. if (res.softbed.softbed_id) {
  341. pageRefresh({
  342. name: "softbedQuoteDetail",
  343. params: {
  344. id: res.softbed.softbed_id,
  345. code: res.softbed.softbed_code
  346. },
  347. query: {
  348. id: res.softbed.softbed_id,
  349. code: res.softbed.softbed_code,
  350. fromCopySave: orderStatus.value == "copy"
  351. }
  352. });
  353. } else {
  354. router.replace("/softbedQuote/index");
  355. }
  356. });
  357. }
  358. }),
  359. buttonDefault({
  360. label: t("common.add"),
  361. power: 152,
  362. limited: () => {
  363. return !!orderStatus.value;
  364. },
  365. clickFunc: item => {
  366. router.push(`/softbedQuote/new?id=0`);
  367. }
  368. }),
  369. buttonDefault({
  370. label: t("common.editText"),
  371. power: 152,
  372. limited: () => {
  373. return !!orderStatus.value;
  374. },
  375. disabledTextCallBack: data => {
  376. if (data.flag == 1) {
  377. return "单据已审核,不能修改";
  378. }
  379. return "";
  380. },
  381. clickFunc: item => {
  382. pageRefresh({
  383. name: "softbedQuoteEdit",
  384. params: {
  385. id: LjDetailRef.value._mainData.softbed_id,
  386. code: LjDetailRef.value._mainData.softbed_code
  387. },
  388. query: {
  389. id: LjDetailRef.value._mainData.softbed_id,
  390. code: LjDetailRef.value._mainData.softbed_code
  391. }
  392. });
  393. // router.replace(
  394. // `/softbedQuote/edit?id=${LjDetailRef.value._mainData.softbed_id}&code=${LjDetailRef.value._mainData.softbed_code}`
  395. // );
  396. }
  397. }),
  398. buttonDefault({
  399. label: t("common.delText"),
  400. power: 155,
  401. loading: () => loadingStatus.value.delete,
  402. limited: () => {
  403. return !!orderStatus.value;
  404. },
  405. disabledTextCallBack: (data: any) => {
  406. if (!CheckPower(155)) {
  407. return "你没有【报价单-删除】的使用权限";
  408. }
  409. return "";
  410. },
  411. clickFunc: item => {
  412. const list = [{ softbed_id: LjDetailRef.value._mainData.softbed_id }];
  413. onDelete(list, () => {
  414. tabRemove(route.fullPath);
  415. router.replace("/softbedQuote");
  416. });
  417. }
  418. }),
  419. buttonDefault({
  420. label: t("common.auditText"),
  421. power: 153,
  422. loading: () => loadingStatus.value.audit,
  423. limited: () => {
  424. return !!orderStatus.value;
  425. },
  426. disabledTextCallBack: (data: any) => {
  427. if (!CheckPower(153)) {
  428. return `你没有【报价单-${t("common.auditText")}】的使用权限`;
  429. }
  430. if (+data.flag === 1) {
  431. return "已审核";
  432. }
  433. return "";
  434. },
  435. clickFunc: item => {
  436. const list = [{ softbed_id: LjDetailRef.value._mainData.softbed_id }];
  437. onAudit(list, () => {
  438. LjDetailRef.value.refresh();
  439. });
  440. }
  441. }),
  442. buttonDefault({
  443. label: t("common.withdrawAuditText"),
  444. power: 154,
  445. loading: () => loadingStatus.value.caudit,
  446. limited: () => {
  447. return !!orderStatus.value;
  448. },
  449. disabledTextCallBack: (data: any) => {
  450. if (!CheckPower(154)) {
  451. return `你没有【报价单-${t("common.withdrawAuditText")}】的使用权限`;
  452. }
  453. if (+data.flag === 0) {
  454. return "未审核";
  455. }
  456. return "";
  457. },
  458. clickFunc: item => {
  459. const list = [{ softbed_id: LjDetailRef.value._mainData.softbed_id }];
  460. onCAudit(list, () => {
  461. LjDetailRef.value.refresh();
  462. });
  463. }
  464. }),
  465. buttonDefault({
  466. label: t("common.showFormula"),
  467. disabledTextCallBack: () => {
  468. return userInfo.usermode == 1 ? "业务员模式不可以查看!" : "";
  469. },
  470. clickFunc: () => {
  471. alert("功能维护中!");
  472. }
  473. }),
  474. buttonDefault({
  475. label: t("common.viewHistoricalQuotes"),
  476. clickFunc: () => {
  477. alert("功能维护中!");
  478. }
  479. }),
  480. buttonDefault({
  481. label: t("common.back"),
  482. clickFunc: item => {
  483. router.push("/softbedQuote/index");
  484. }
  485. })
  486. ];
  487. /**
  488. * @description 页面数据加载完成
  489. */
  490. const funcAfterMound = async (data: any) => {
  491. // console.log("onMounted detail start!!!! :>> ", orderStatus.value, data, route, router);
  492. if (!orderStatus.value) {
  493. // 详情页
  494. } else {
  495. // 新增/编辑
  496. tableProps.value.editConfig.enabled = true;
  497. tableProps_mx.value.editConfig.enabled = true;
  498. }
  499. if (orderStatus.value != "new") {
  500. initParams.value.billid = Number(route.query.id);
  501. detail_getData(initParams.value);
  502. }
  503. };
  504. onMounted(() => {
  505. GetSoftBedFormulaMapper();
  506. GetSoftBedAccessoryMapper();
  507. });
  508. // 返回绑定的事件
  509. const tableEvents = {};
  510. </script>
  511. <style lang="scss">
  512. .select-text-right {
  513. .el-select__wrapper {
  514. text-align: right;
  515. }
  516. }
  517. </style>