index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div class="table-box">
  3. <LjVxeTable
  4. ref="VxeTableRef"
  5. row-key="softbed_id"
  6. :columns="columns"
  7. :init-param="initParams"
  8. :request-api="getData"
  9. :data-callback="dataCallback"
  10. :dwname="DwnameEnum.softbedQuote"
  11. :table-props="tableProps"
  12. :table-events="tableEvents"
  13. :auto-load-layout="false"
  14. :search-btn-size-extent="[]"
  15. pagination
  16. >
  17. <!-- 表格 header 按钮 -->
  18. <template #tableHeader>
  19. <LjHeaderMenu :action="action" />
  20. </template>
  21. </LjVxeTable>
  22. </div>
  23. <BedConfigModal
  24. v-model="isModalVisible"
  25. v-model:showHeadboard="showHeadboard"
  26. v-model:showNightstand="showNightstand"
  27. v-model:showBedframe="showBedframe"
  28. v-model:partsConfig="partsConfig"
  29. :configItemOptions="allConfigItemOptions"
  30. :configValueOptionsMap="configValueOptionsMap"
  31. @submit="handleConfirm"
  32. />
  33. </template>
  34. <script setup lang="ts" name="softbedQuote">
  35. import { ref, reactive } from "vue";
  36. import { useRouter } from "vue-router";
  37. import { CommonDynamicSelect } from "@/api/modules/common";
  38. import { useHooks } from "./hooks/index";
  39. import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
  40. import { useI18n } from "vue-i18n";
  41. import { useAuthButtons } from "@/hooks/useAuthButtons";
  42. import { DwnameEnum } from "@/enums/dwnameEnum";
  43. import { formatToDateTime, formatToDate } from "@/utils/dateUtil";
  44. import { cloneDeep } from "lodash-es";
  45. import { useGlobalStore } from "@/stores/modules/global";
  46. import { ElMessage, ElMessageBox } from "element-plus";
  47. import { detailAction } from "@/components/LjDetail/interface";
  48. import { useUserStore } from "@/stores/modules/user";
  49. import { getCurrentRecords } from "@/utils/index";
  50. const { t } = useI18n();
  51. const router = useRouter();
  52. const globalStore = useGlobalStore();
  53. const { columns, orderStatus, VxeTableRef, initParams, onAudit, onCAudit, onDelete, onShowFormula } = useHooks(t);
  54. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  55. const { userInfo } = useUserStore();
  56. const allConfigItemOptions = reactive([
  57. { pzid: 101, pzname: "颜色" },
  58. { pzid: 201, pzname: "材质" },
  59. { pzid: 301, pzname: "款式" },
  60. { pzid: 401, pzname: "尺寸" },
  61. { pzid: 501, pzname: "填充物" },
  62. { pzid: 601, pzname: "靠背调节" }
  63. ]);
  64. const configValueOptionsMap = reactive({
  65. 101: [
  66. { printid: 1, pznamemx: "白色" },
  67. { printid: 2, pznamemx: "红色" }
  68. ],
  69. 201: [
  70. { printid: 1, pznamemx: "皮质" },
  71. { printid: 2, pznamemx: "布艺" }
  72. ],
  73. 301: [{ printid: 1, pznamemx: "简约款" }],
  74. 401: [{ printid: 1, pznamemx: "1.8米" }],
  75. 501: [{ printid: 1, pznamemx: "记忆棉" }],
  76. 601: [{ printid: 1, pznamemx: "不可调节" }]
  77. });
  78. // 父组件维护 partsConfig,Modal 每次打开都会使用同一个对象(记忆性)
  79. const partsConfig = reactive({
  80. headboard: [
  81. { pzid: 101, selectedValue: "白色" },
  82. { pzid: 201, selectedValue: "皮质" }
  83. ],
  84. nightstand: [
  85. { pzid: 101, selectedValue: "白色" },
  86. { pzid: 301, selectedValue: "欧式款" }
  87. ],
  88. bedframe: [
  89. { pzid: 101, selectedValue: "灰色" },
  90. { pzid: 401, selectedValue: "1.8米" }
  91. ]
  92. });
  93. const showHeadboard = ref(true);
  94. const showNightstand = ref(true);
  95. const showBedframe = ref(true);
  96. // 控制弹窗的显示状态
  97. const isModalVisible = ref(false);
  98. const getData = (params: any) => {
  99. let newParams: any = {};
  100. params.pageNum && (newParams.pageindex = params.pageNum);
  101. params.pageSize && (newParams.pagesize = params.pageSize);
  102. params.orderstr && (newParams.orderstr = params.orderstr);
  103. delete params.pageNum;
  104. delete params.pageSize;
  105. delete params.orderstr;
  106. let _params = cloneDeep(params);
  107. newParams.queryParams = _params;
  108. newParams.dsname = "web_softbed_list";
  109. return CommonDynamicSelect(newParams, DwnameEnum.softbedQuote);
  110. };
  111. const dataCallback = (data: any) => {
  112. return {
  113. list: data.datatable,
  114. tableinfo: data.tableinfo,
  115. total: data.totalcnt,
  116. pageNum: data.pageindex,
  117. pageSize: data.pagesize
  118. };
  119. };
  120. const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  121. //
  122. if (globalStore.detailBlank) {
  123. // 打开新的窗口
  124. const routeUrl = router.resolve({
  125. path: `/softbedQuote/detail`,
  126. query: {
  127. id: row.softbed_id,
  128. code: row.softbed_code
  129. }
  130. });
  131. window.open(routeUrl.href, "_blank");
  132. } else {
  133. // 打开新的标签页
  134. router.push(`/softbedQuote/detail?id=${row.softbed_id}&code=${row.softbed_code}`);
  135. }
  136. };
  137. const rowClsNameFunc = (data: any) => {
  138. const { row, rowIndex, $rowIndex } = data;
  139. return "";
  140. };
  141. const tableProps = {
  142. height: "auto",
  143. editConfig: { trigger: "click", mode: "cell" },
  144. rowClassName: rowClsNameFunc,
  145. exportConfig: {
  146. filename: t("menu.softbedQuote") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  147. }
  148. };
  149. // 返回绑定的事件
  150. const tableEvents = {
  151. "cell-dblclick": handleDBlClickTable
  152. };
  153. /**
  154. * @description 按钮展示
  155. */
  156. const action: detailAction[] = [
  157. buttonDefault({
  158. label: t("common.redo"),
  159. clickFunc: item => {
  160. VxeTableRef.value.refresh();
  161. }
  162. }),
  163. buttonDefault({
  164. label: t("common.add"),
  165. power: 124,
  166. clickFunc: item => {
  167. router.push(`/softbedQuote/new?id=0`);
  168. }
  169. }),
  170. buttonDefault({
  171. label: t("common.editText"),
  172. power: 124,
  173. clickFunc: item => {
  174. const { $table, curRecords } = getCurrentRecords(VxeTableRef.value);
  175. if (!curRecords.length) {
  176. ElMessage.warning(t("business.tips.mattress.records"));
  177. return;
  178. }
  179. const _cur = curRecords[curRecords.length - 1];
  180. if (_cur.flag == 1) {
  181. ElMessage.warning("单据已审核,不能修改");
  182. return;
  183. }
  184. router.push(`/softbedQuote/edit?id=${_cur.softbed_id}&code=${_cur.softbed_code}`);
  185. }
  186. }),
  187. buttonDefault({
  188. label: t("common.delText"),
  189. power: 127,
  190. disabledTextCallBack: (data: any) => {
  191. if (!CheckPower(127)) {
  192. return "你没有【报价单-删除】的使用权限";
  193. }
  194. return "";
  195. },
  196. clickFunc: item => {
  197. const { curRecords } = getCurrentRecords(VxeTableRef.value);
  198. if (!curRecords.length) {
  199. ElMessage.warning(t("business.tips.mattress.records"));
  200. return;
  201. }
  202. let list = curRecords.map((item: any) => {
  203. return { softbed_id: Number(item.softbed_id) };
  204. });
  205. onDelete(list);
  206. }
  207. }),
  208. buttonDefault({
  209. label: t("common.auditText"),
  210. power: 125,
  211. limited: () => {
  212. return !!orderStatus.value;
  213. },
  214. disabledTextCallBack: (data: any) => {
  215. if (!CheckPower(125)) {
  216. return `你没有【报价单-${t("common.auditText")}】的使用权限`;
  217. }
  218. return "";
  219. },
  220. clickFunc: item => {
  221. const { curRecords } = getCurrentRecords(VxeTableRef.value);
  222. let list = curRecords.map((item: any) => {
  223. return { softbed_id: Number(item.softbed_id) };
  224. });
  225. onAudit(list, () => {
  226. VxeTableRef.value.refresh();
  227. });
  228. }
  229. }),
  230. buttonDefault({
  231. label: t("common.withdrawAuditText"),
  232. power: 125,
  233. limited: () => {
  234. return !!orderStatus.value;
  235. },
  236. disabledTextCallBack: (data: any) => {
  237. if (!CheckPower(125)) {
  238. return `你没有【报价单-${t("common.withdrawAuditText")}】的使用权限`;
  239. }
  240. return "";
  241. },
  242. clickFunc: item => {
  243. const { curRecords } = getCurrentRecords(VxeTableRef.value);
  244. let list = curRecords.map((item: any) => {
  245. return { softbed_id: Number(item.softbed_id) };
  246. });
  247. onCAudit(list),
  248. () => {
  249. VxeTableRef.value.refresh();
  250. };
  251. }
  252. }),
  253. buttonDefault({
  254. label: t("common.copyQuote"),
  255. power: 75,
  256. clickFunc: item => {
  257. const { $table, curRecords } = getCurrentRecords(VxeTableRef.value);
  258. if (!curRecords.length) {
  259. ElMessage.warning(t("business.tips.mattress.records"));
  260. return;
  261. }
  262. const _cur = $table.getCurrentRecord() ?? null;
  263. if (_cur) {
  264. router.push(`/softbedQuote/copy?id=${_cur.softbed_id}&code=${_cur.softbed_code}`);
  265. } else {
  266. const _cur = curRecords[curRecords.length - 1];
  267. router.push(`/softbedQuote/copy?id=${_cur.softbed_id}&code=${_cur.softbed_code}`);
  268. }
  269. }
  270. }),
  271. buttonDefault({
  272. label: t("common.showFormula"),
  273. disabledTextCallBack: () => {
  274. return userInfo.usermode == 1 ? "业务员模式不可以查看!" : "";
  275. },
  276. clickFunc: item => {}
  277. }),
  278. buttonDefault({
  279. label: t("common.viewHistoricalQuotes"),
  280. power: 61,
  281. clickFunc: item => {}
  282. }),
  283. buttonDefault({
  284. label: t("common.dataTransmission"),
  285. power: 61,
  286. clickFunc: item => {}
  287. })
  288. ];
  289. const handleConfirm = data => {
  290. isModalVisible.value = false;
  291. console.log("showHeadboard :>>", showHeadboard);
  292. console.log("showNightstand :>>", showNightstand);
  293. console.log("showBedframe :>>", showBedframe);
  294. console.log("partsConfig :>>", data);
  295. };
  296. </script>