index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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.mattressQuote"
  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 :update="dialogVisible" :action="action" />
  20. </template>
  21. </LjVxeTable>
  22. </div>
  23. <el-dialog v-model="dialogFormVisible" title="部门选择" width="500" draggable append-to-body>
  24. <el-form :model="formParam" label-width="80px">
  25. <el-form-item label="部门">
  26. <el-select v-model="formParam.deptid" placeholder="请选择部门">
  27. <el-option v-for="(col, index) in deptEnum" :key="index" :label="col.label" :value="col.value"></el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="地区">
  31. <el-select v-model="formParam.area">
  32. <el-option label="维持原状" value="维持原状" />
  33. <el-option label="普通地区" value="普通地区" />
  34. <el-option label="特定地区" value="特定地区" />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="柜型">
  38. <el-select v-model="formParam.cabinet_type">
  39. <el-option label="维持原状" value="维持原状" />
  40. <el-option label="大柜" value="大柜" />
  41. <el-option label="小柜" value="小柜" />
  42. </el-select>
  43. </el-form-item>
  44. <el-form-item label="压包数量" v-if="formParam.packtype == 0">
  45. <el-input-number v-model="formParam.packqty" :min="0" :max="1000" />
  46. </el-form-item>
  47. </el-form>
  48. <template #footer>
  49. <div class="dialog-footer">
  50. <el-button @click="dialogFormVisible = false">取消</el-button>
  51. <el-button type="primary" @click="BatchCopyMattressAudited">确认</el-button>
  52. </div>
  53. </template>
  54. </el-dialog>
  55. </template>
  56. <script setup lang="ts" name="mattressQuote">
  57. import { ref, onMounted, inject } from "vue";
  58. import { useRouter } from "vue-router";
  59. import {
  60. SaveMattressAuditing,
  61. DelMattress,
  62. CopyMattressAudited,
  63. ReCalculateNoAudit,
  64. ReCalculateERPCost
  65. } from "@/api/modules/quote";
  66. import { CommonDynamicSelect } from "@/api/modules/common";
  67. import { ColumnProps } from "@/components/LjVxeTable/interface";
  68. import LjDrawer from "@/components/LjDrawer/index.vue";
  69. // import PriceListDetail from "./detail.vue";
  70. import { useHooks } from "./hooks/index";
  71. import { useHooksCpQuote } from "./hooks/cpQuote";
  72. import LjDialog from "@/components/LjDialog/index.vue";
  73. import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
  74. import { useI18n } from "vue-i18n";
  75. import { useAuthButtons } from "@/hooks/useAuthButtons";
  76. import { DwnameEnum } from "@/enums/dwnameEnum";
  77. import { formatToDateTime, formatToDate } from "@/utils/dateUtil";
  78. import { cloneDeep } from "lodash-es";
  79. import { useGlobalStore } from "@/stores/modules/global";
  80. import { ElMessage, ElMessageBox } from "element-plus";
  81. import { detailAction } from "@/components/LjDetail/interface";
  82. import mittBus from "@/utils/mittBus";
  83. import { MittEnum } from "@/enums/mittEnum";
  84. import { getCurrentRecords } from "@/utils/index";
  85. import { useUserStore } from "@/stores/modules/user";
  86. const { t } = useI18n();
  87. const router = useRouter();
  88. const globalStore = useGlobalStore();
  89. const { vxeTableRef, columns, initParams, dataCallback, gotoErpapi } = useHooks();
  90. const { toExcelQuote } = useHooksCpQuote();
  91. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  92. // const initParams = ref({});
  93. const dialogVisible = ref(false);
  94. // const vxeTableRef = ref();
  95. const dialogFormVisible = ref(false);
  96. const deptEnum = ref([]);
  97. const formParam = ref({
  98. deptid: 0,
  99. area: "维持原状",
  100. cabinet_type: "维持原状",
  101. packtype: 0,
  102. packqty: 0
  103. });
  104. const getData = (params: any) => {
  105. console.log("getData mattress params :>> ", params);
  106. let newParams: any = {};
  107. params.pageNum && (newParams.pageindex = params.pageNum);
  108. params.pageSize && (newParams.pagesize = params.pageSize);
  109. params.orderstr && (newParams.orderstr = params.orderstr);
  110. delete params.arg_mattressid;
  111. delete params.pageNum;
  112. delete params.pageSize;
  113. delete params.orderstr;
  114. let _params = cloneDeep(params);
  115. switch (_params.status_flag) {
  116. case "1": // 待下单
  117. _params.arg_xd_flag = 0;
  118. break;
  119. case "2": // 已下单
  120. _params.arg_xd_flag = 1;
  121. break;
  122. case "3": // 待财务审核
  123. _params.arg_cp_flag = 1;
  124. _params.arg_flag = 0;
  125. break;
  126. case "4": // 已财务审核
  127. _params.arg_flag = 1;
  128. break;
  129. default:
  130. break;
  131. }
  132. newParams.queryParams = _params;
  133. newParams.dsname = "web_mattress";
  134. return CommonDynamicSelect(newParams, DwnameEnum.mattressQuote);
  135. // return [];
  136. };
  137. const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  138. if (globalStore.detailBlank) {
  139. // 打开新的窗口
  140. const routeUrl = router.resolve({
  141. path: `/mattressQuote/detail`,
  142. query: {
  143. id: row.mattressid,
  144. code: row.mattresscode
  145. }
  146. });
  147. window.open(routeUrl.href, "_blank");
  148. } else {
  149. // if (currentLayout.value.right.hidden && globalStore.mxFloat?.includes("custCrmDetail")) {
  150. // // 弹窗
  151. // mainData.value = row;
  152. // LjDrawerRef.value.show();
  153. // } else {
  154. // 打开新的标签页
  155. router.push(`/mattressQuote/detail?id=${row.mattressid}&code=${row.mattresscode}`);
  156. // }
  157. }
  158. };
  159. const rowClsNameFunc = (data: any) => {
  160. const { row, rowIndex, $rowIndex } = data;
  161. if (Number(row.flag) == 0) {
  162. if (Number(row.xd_flag) == 0) {
  163. return "vxecol-danger";
  164. }
  165. if (Number(row.xd_flag) == 1) {
  166. return "vxecol-blue";
  167. }
  168. }
  169. return "";
  170. };
  171. const tableProps = {
  172. height: "auto",
  173. editConfig: { trigger: "click", mode: "cell" },
  174. rowClassName: rowClsNameFunc,
  175. exportConfig: {
  176. filename: t("menu.rpMsttake") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  177. },
  178. treeConfig: {
  179. expandAll: true,
  180. transform: true,
  181. rowField: "mattressid",
  182. parentField: "parentid"
  183. },
  184. checkboxConfig: {
  185. checkStrictly: true
  186. }
  187. };
  188. // 返回绑定的事件
  189. const tableEvents = {
  190. // "checkbox-change": handleCheckboxChange,
  191. // "checkbox-all": handleCheckboxChange,
  192. // "checkbox-range-change": handleCheckboxChange,
  193. // "current-change": handleCurrentChanged
  194. "cell-dblclick": handleDBlClickTable
  195. // "cell-click": handleClickTable
  196. };
  197. onMounted(() => {
  198. dialogVisible.value = true;
  199. });
  200. /**
  201. * @description 业务下单或财务审核操作
  202. * @param params 对象,入参
  203. */
  204. const toAuditing = (params: any, message: string) => {
  205. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  206. console.log("curRecords :>> ", curRecords);
  207. if (!curRecords.length) {
  208. ElMessage.warning(t("business.tips.mattress.records"));
  209. return;
  210. }
  211. let _mattressids = curRecords.map((item: any) => Number(item.mattressid));
  212. ElMessageBox.confirm(`是否确定要对${curRecords.length}张床垫报价单进行操作`, "询问", {
  213. confirmButtonText: message,
  214. cancelButtonText: "否",
  215. type: "warning"
  216. })
  217. .then(() => {
  218. let _params = {
  219. ...params,
  220. mattressids: _mattressids
  221. };
  222. SaveMattressAuditing(_params).then(() => {
  223. ElMessage.success(t("sys.api.operationSuccess"));
  224. vxeTableRef.value.refresh();
  225. });
  226. })
  227. .catch((e: TypeError) => {
  228. ElMessage({
  229. type: "info",
  230. message: "操作取消"
  231. });
  232. });
  233. };
  234. /**
  235. * @description 按钮展示
  236. */
  237. const action: detailAction[] = [
  238. buttonDefault({
  239. label: t("common.redo"),
  240. clickFunc: item => {
  241. vxeTableRef.value.refresh();
  242. }
  243. }),
  244. buttonDefault({
  245. label: t("common.add"),
  246. power: 72,
  247. clickFunc: item => {
  248. console.log("inewss nitParams.value :>> ", vxeTableRef.value.searchParam);
  249. let _deptid = 0;
  250. if (Object.keys(vxeTableRef.value.searchParam).includes("arg_deptid")) {
  251. _deptid = vxeTableRef.value.searchParam.arg_deptid ?? 0;
  252. }
  253. if (_deptid == 0) {
  254. let enumMap = vxeTableRef.value.enumMap;
  255. let enumdata = enumMap.get("deptid");
  256. if (enumdata && enumdata.length > 0) {
  257. _deptid = enumdata[0].value;
  258. }
  259. }
  260. router.push(`/mattressQuote/new?id=0&deptid=${_deptid}`);
  261. }
  262. }),
  263. buttonDefault({
  264. label: t("common.editText"),
  265. power: 72,
  266. clickFunc: item => {
  267. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  268. if (!curRecords.length) {
  269. ElMessage.warning(t("business.tips.mattress.records"));
  270. return;
  271. }
  272. const _cur = curRecords[curRecords.length - 1];
  273. console.log("修改 _cur :>> ", _cur);
  274. if (_cur.parentid > 0) {
  275. ElMessage.warning("副规格无法编辑");
  276. return;
  277. }
  278. if (_cur.yw_flag == 1) {
  279. ElMessage.warning("已业务补充审核,无法修改");
  280. return;
  281. }
  282. if (_cur.flag == 1) {
  283. ElMessage.warning("单据已审核,不能修改");
  284. return;
  285. }
  286. router.push(`/mattressQuote/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}`);
  287. }
  288. }),
  289. buttonDefault({
  290. label: t("common.delText"),
  291. power: 77,
  292. disabledTextCallBack: (data: any) => {
  293. if (!CheckPower(77)) {
  294. return "你没有【报价单-删除】的使用权限";
  295. }
  296. return "";
  297. },
  298. clickFunc: item => {
  299. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  300. console.log("curRecords :>> ", curRecords);
  301. if (!curRecords.length) {
  302. ElMessage.warning(t("business.tips.mattress.records"));
  303. return;
  304. }
  305. const { userInfo } = useUserStore();
  306. try {
  307. curRecords.map(item => {
  308. if (item.createby !== userInfo.username && userInfo.empid != 0) {
  309. throw new Error("只能删除自己创建的报价单");
  310. }
  311. });
  312. } catch (error) {
  313. ElMessage.error(error.message);
  314. return false;
  315. }
  316. let _mattressids = curRecords.map((item: any) => Number(item.mattressid));
  317. ElMessageBox.confirm(`是否确定要删除${curRecords.length}张床垫报价单(及其副规格报价单)吗?`, "询问", {
  318. confirmButtonText: t("common.delText"),
  319. cancelButtonText: "否",
  320. type: "warning"
  321. })
  322. .then(() => {
  323. DelMattress({ mattressids: _mattressids }).then(() => {
  324. ElMessage.success("删除成功!");
  325. vxeTableRef.value.refresh();
  326. });
  327. })
  328. .catch((e: TypeError) => {
  329. console.log("e :>> ", e);
  330. ElMessage({
  331. type: "info",
  332. message: "操作取消"
  333. });
  334. });
  335. }
  336. }),
  337. buttonDefault({
  338. label: t("common.copyQuote"),
  339. power: 75,
  340. clickFunc: item => {
  341. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  342. if (!curRecords.length) {
  343. ElMessage.warning(t("business.tips.mattress.records"));
  344. return;
  345. }
  346. let _cur = $table.getCurrentRecord() ?? null;
  347. if (!_cur) {
  348. _cur = curRecords[curRecords.length - 1];
  349. }
  350. router.push(`/mattressQuote/copy?id=${_cur.mattressid}&code=${_cur.mattresscode}`);
  351. }
  352. }),
  353. // [
  354. buttonDefault({
  355. label: t("common.businessOrder"),
  356. power: 94,
  357. clickFunc: item => {
  358. toAuditing({ xd_flag: 1 }, t("common.businessOrder"));
  359. }
  360. }),
  361. buttonDefault({
  362. label: t("common.businessOrderCancel"),
  363. power: 95,
  364. clickFunc: item => {
  365. toAuditing({ xd_flag: 0 }, t("common.businessOrder"));
  366. }
  367. }),
  368. // ],
  369. // [
  370. buttonDefault({
  371. label: t("common.auditFinance"),
  372. power: 73,
  373. clickFunc: item => {
  374. toAuditing({ flag: 1 }, t("common.auditFinance"));
  375. }
  376. }),
  377. buttonDefault({
  378. label: t("common.withdrawAuditFinance"),
  379. power: 74,
  380. clickFunc: item => {
  381. toAuditing({ flag: 0 }, t("common.withdrawAuditFinance"));
  382. }
  383. }),
  384. // ],
  385. buttonDefault({
  386. label: t("common.copyFromMulitFlag"),
  387. power: 75,
  388. clickFunc: async item => {
  389. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  390. console.log("curRecords :>> ", curRecords);
  391. if (!curRecords.length) {
  392. ElMessage.warning(t("business.tips.mattress.records"));
  393. return;
  394. }
  395. await openDeptChoosen(curRecords);
  396. }
  397. }),
  398. buttonDefault({
  399. label: t("common.recalculateFromNotFlag"),
  400. power: 72,
  401. clickFunc: item => {
  402. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  403. console.log("curRecords :>> ", curRecords);
  404. if (!curRecords.length) {
  405. ElMessage.warning(t("business.tips.mattress.records"));
  406. return;
  407. }
  408. let list = curRecords.map((item: any) => {
  409. return { mattressid: Number(item.mattressid) };
  410. });
  411. ElMessageBox.confirm(`是否确定要批重算${curRecords.length}张床垫报价单吗?`, "询问", {
  412. confirmButtonText: t("common.okText"),
  413. cancelButtonText: "否",
  414. type: "warning"
  415. })
  416. .then(() => {
  417. ReCalculateNoAudit({ list }).then(() => {
  418. ElMessage.success("批重算成功!");
  419. vxeTableRef.value.refresh();
  420. });
  421. })
  422. .catch((e: TypeError) => {
  423. console.log("e :>> ", e);
  424. ElMessage({
  425. type: "info",
  426. message: "操作取消"
  427. });
  428. });
  429. }
  430. }),
  431. buttonDefault({
  432. label: t("common.viewHistoricalQuotes"),
  433. power: 72,
  434. clickFunc: item => {
  435. alert("功能维护中!");
  436. }
  437. }),
  438. buttonDefault({
  439. label: t("common.showQuoteList"),
  440. power: 72,
  441. clickFunc: item => {
  442. alert("功能维护中!");
  443. }
  444. }),
  445. buttonDefault({
  446. label: t("common.dataTransmission"),
  447. power: 72,
  448. clickFunc: item => {
  449. alert("功能维护中!");
  450. }
  451. }),
  452. buttonDefault({
  453. label: t("common.businessSupplement"),
  454. power: 72,
  455. clickFunc: item => {
  456. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  457. if (!curRecords.length) {
  458. ElMessage.warning(t("business.tips.mattress.records"));
  459. return;
  460. }
  461. let _cur = $table.getCurrentRecord() ?? curRecords[curRecords.length - 1];
  462. let type = 1;
  463. // router.push(`/erpapi/mattressInterface/${type}/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}&type=${type}`);
  464. gotoErpapi(_cur, type);
  465. }
  466. }),
  467. buttonDefault({
  468. label: t("common.recalculateERPCost"),
  469. power: 72,
  470. clickFunc: async item => {
  471. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  472. console.log("curRecords :>> ", curRecords);
  473. if (!curRecords.length) {
  474. ElMessage.warning(t("business.tips.mattress.records"));
  475. return;
  476. }
  477. let list = curRecords.map((item: any) => {
  478. return { mattressid: Number(item.mattressid) };
  479. });
  480. ElMessageBox.confirm(`是否确定要批重算${curRecords.length}张床垫报价单吗?`, "询问", {
  481. confirmButtonText: t("common.okText"),
  482. cancelButtonText: "否",
  483. type: "warning"
  484. })
  485. .then(() => {
  486. ReCalculateERPCost({ list }).then((res: any) => {
  487. ElMessage.success(res.logMsg);
  488. vxeTableRef.value.refresh();
  489. });
  490. })
  491. .catch((e: TypeError) => {
  492. ElMessage({
  493. type: "info",
  494. message: "操作取消"
  495. });
  496. });
  497. }
  498. })
  499. ];
  500. const openDeptChoosen = async curRecords => {
  501. try {
  502. // let newParams = {
  503. // dsname: "_Mapper_deptid",
  504. // queryparams: {}
  505. // };
  506. // let res = await CommonDynamicSelect(newParams);
  507. // if (res.datatable) {
  508. // deptEnum.value = res.datatable?.map((item: any) => {
  509. // return { label: item.deptname, value: item.deptid };
  510. // });
  511. // }
  512. let enumMap = vxeTableRef.value.enumMap;
  513. deptEnum.value = enumMap.get("deptid");
  514. console.log("openDeptChoosen deptEnum.value :>> ", deptEnum.value);
  515. if (deptEnum.value.length > 0) {
  516. formParam.value.deptid = curRecords[0].deptid;
  517. formParam.value.packtype = curRecords[0].packtype;
  518. formParam.value.packqty = curRecords[0].packqty;
  519. dialogFormVisible.value = true;
  520. } else {
  521. console.error("获取部门列表为空");
  522. }
  523. } catch (error) {
  524. console.error("获取部门列表失败", error);
  525. }
  526. };
  527. const BatchCopyMattressAudited = () => {
  528. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  529. console.log("curRecords :>> ", curRecords);
  530. if (!curRecords.length) {
  531. ElMessage.warning(t("business.tips.mattress.records"));
  532. return;
  533. }
  534. let list = curRecords.map((item: any) => {
  535. return {
  536. mattressid: Number(item.mattressid),
  537. deptid: formParam.value.deptid,
  538. area: formParam.value.area,
  539. cabinet_type: formParam.value.cabinet_type,
  540. packtype: formParam.value.packtype,
  541. packqty: formParam.value.packqty
  542. };
  543. });
  544. ElMessageBox.confirm(`是否确定要批复制${curRecords.length}张床垫报价单吗?`, "询问", {
  545. confirmButtonText: t("common.okText"),
  546. cancelButtonText: "否",
  547. type: "warning"
  548. })
  549. .then(() => {
  550. CopyMattressAudited({ list }).then(() => {
  551. ElMessage.success("批复制成功!");
  552. dialogFormVisible.value = false;
  553. vxeTableRef.value.refresh();
  554. });
  555. })
  556. .catch((e: TypeError) => {
  557. console.log("e :>> ", e);
  558. ElMessage({
  559. type: "info",
  560. message: "操作取消"
  561. });
  562. });
  563. };
  564. /**
  565. * @description 监听框架属性变化
  566. */
  567. mittBus.on(MittEnum.MattressList, () => {
  568. vxeTableRef.value.refresh();
  569. });
  570. </script>