index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  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. :page-change-call-back="autoUpdateTableCheckbox"
  17. >
  18. <!-- 表格 header 按钮 -->
  19. <template #tableHeader>
  20. <LjHeaderMenu :update="dialogVisible" :action="action" />
  21. </template>
  22. </LjVxeTable>
  23. </div>
  24. <el-dialog v-model="dialogFormVisible" title="部门选择" width="500" draggable append-to-body>
  25. <el-form :model="formParam" label-width="80px">
  26. <el-form-item label="部门">
  27. <el-select v-model="formParam.deptid" placeholder="请选择部门" filterable @change="wf_get_moneyrate_discount">
  28. <el-option v-for="(col, index) in deptEnum" :key="index" :label="col.label" :value="col.value"></el-option>
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item label="地区">
  32. <el-select v-model="formParam.area">
  33. <el-option label="维持原状" value="维持原状" />
  34. <el-option label="普通地区" value="普通地区" />
  35. <el-option label="特定地区" value="特定地区" />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="柜型">
  39. <el-select v-model="formParam.cabinet_type">
  40. <el-option label="维持原状" value="维持原状" />
  41. <el-option label="大柜" value="大柜" />
  42. <el-option label="小柜" value="小柜" />
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="佣金点数">
  46. <el-input-number v-model="formParam.commission" />
  47. </el-form-item>
  48. <el-form-item label="税金">
  49. <el-select v-model="formParam.taxes" class="select-text-right">
  50. <template #prefix>
  51. <span>{{ formParam.taxes }}</span>
  52. </template>
  53. <el-option label="不含税" :value="1" />
  54. <el-option label="含税" :value="1.07" />
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item label="额外点数">
  58. <el-input-number v-model="formParam.other_rate" />
  59. </el-form-item>
  60. <el-form-item label="额外费用">
  61. <el-input-number v-model="formParam.extras_cost" />
  62. </el-form-item>
  63. <el-form-item label="币种">
  64. <el-select v-model="formParam.moneytype" class="select-text-right" @change="wf_get_moneyrate_discount">
  65. <template #prefix>
  66. <span>{{ formParam.moneyrate }}</span>
  67. </template>
  68. <el-option label="人民币" :value="0" />
  69. <el-option label="美元" :value="1" />
  70. </el-select>
  71. </el-form-item>
  72. <el-form-item label="压包数量" v-if="formParam.packtype == 0">
  73. <el-input-number v-model="formParam.packqty" :min="0" :max="1000" />
  74. </el-form-item>
  75. <el-form-item label="复制到">
  76. <el-select v-model="formParam.createby" :placeholder="userInfo.username" filterable clearable>
  77. <el-option v-for="(col, index) in userListData" :key="index" :label="col.username" :value="col.username"></el-option>
  78. </el-select>
  79. </el-form-item>
  80. </el-form>
  81. <template #footer>
  82. <div class="dialog-footer">
  83. <el-button @click="dialogFormVisible = false">取消</el-button>
  84. <el-button type="primary" :loading="loadingBtn" @click="BatchCopyMattressAudited">确认</el-button>
  85. </div>
  86. </template>
  87. </el-dialog>
  88. <LjDrawerQuoteList
  89. ref="QuoteListDrawerRef"
  90. :iforigin="isShowOriginFormulaMattress"
  91. @closed="ifShowDrawer = false"
  92. @export="handleExportQuote"
  93. />
  94. </template>
  95. <script setup lang="ts" name="mattressQuote">
  96. import { ref, onMounted, inject, reactive } from "vue";
  97. import { useRouter } from "vue-router";
  98. import {
  99. SaveMattressAuditing,
  100. DelMattress,
  101. CopyMattressAudited,
  102. ReCalculateNoAudit,
  103. ReCalculateERPCost,
  104. GetComputeMattressById
  105. } from "@/api/modules/quote";
  106. import { getUserList } from "@/api/modules/basicinfo";
  107. import { CommonDynamicSelect } from "@/api/modules/common";
  108. import { ColumnProps } from "@/components/LjVxeTable/interface";
  109. import LjDrawer from "@/components/LjDrawer/index.vue";
  110. // import PriceListDetail from "./detail.vue";
  111. import { useHooks } from "./hooks/index";
  112. import { useHooksCpQuote } from "./hooks/cpQuote";
  113. import LjDialog from "@/components/LjDialog/index.vue";
  114. import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
  115. import { useI18n } from "vue-i18n";
  116. import { useAuthButtons } from "@/hooks/useAuthButtons";
  117. import { DwnameEnum } from "@/enums/dwnameEnum";
  118. import { formatToDateTime, formatToDate } from "@/utils/dateUtil";
  119. import { cloneDeep } from "lodash-es";
  120. import { useGlobalStore } from "@/stores/modules/global";
  121. import { ElMessage, ElMessageBox } from "element-plus";
  122. import { detailAction } from "@/components/LjDetail/interface";
  123. import mittBus from "@/utils/mittBus";
  124. import { MittEnum } from "@/enums/mittEnum";
  125. import { getCurrentRecords } from "@/utils/index";
  126. import { useUserStore } from "@/stores/modules/user";
  127. import LjDrawerQuoteList from "./components/QuoteListNew.vue";
  128. import { storeToRefs } from "pinia";
  129. import { formatTime } from "@/utils/index";
  130. import { usePageRouter } from "@/hooks/usePageRouter";
  131. const { t } = useI18n();
  132. const router = useRouter();
  133. const globalStore = useGlobalStore();
  134. const {
  135. vxeTableRef,
  136. columns,
  137. initParams,
  138. dataCallback,
  139. gotoErpapi,
  140. getFormulakindEnum,
  141. formulaKindEnum,
  142. fabricMxTabList,
  143. funcChaifenTabPro,
  144. getQuoteListMxData,
  145. gotoHisprice
  146. } = useHooks();
  147. const { toExcelQuote, toExcelQuoteNew } = useHooksCpQuote();
  148. const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
  149. const { userInfo } = useUserStore();
  150. const { pageCheckRefresh, pageCheckOpen } = usePageRouter();
  151. // const initParams = ref({});
  152. const dialogVisible = ref(false);
  153. // const vxeTableRef = ref();
  154. const dialogFormVisible = ref(false);
  155. const loadingBtn = ref(false);
  156. const deptEnum = ref([]);
  157. const userListData = ref([]);
  158. const QuoteListDrawerRef = ref(null);
  159. const ifShowDrawer = ref(false);
  160. const ifShowHisprice = ref(false);
  161. const { isShowOriginFormulaMattress } = storeToRefs(globalStore);
  162. const loadingStatus = reactive({
  163. showQd: false,
  164. download: false
  165. });
  166. const formParam = ref({
  167. deptid: 0,
  168. area: "维持原状",
  169. cabinet_type: "维持原状",
  170. packtype: 0,
  171. packqty: 0,
  172. createby: "",
  173. commission: 0,
  174. taxes: 1,
  175. other_rate: 0,
  176. extras_cost: 0,
  177. moneytype: 0,
  178. moneyrate: 1,
  179. discount: 0
  180. });
  181. const getData = (params: any) => {
  182. console.log("getData mattress params :>> ", params);
  183. let newParams: any = {};
  184. params.pageNum && (newParams.pageindex = params.pageNum);
  185. params.pageSize && (newParams.pagesize = params.pageSize);
  186. params.orderstr && (newParams.orderstr = params.orderstr);
  187. delete params.arg_mattressid;
  188. delete params.pageNum;
  189. delete params.pageSize;
  190. delete params.orderstr;
  191. let _params = cloneDeep(params);
  192. switch (_params.status_flag) {
  193. case "1": // 待下单
  194. _params.arg_xd_flag = 0;
  195. break;
  196. case "2": // 已下单
  197. _params.arg_xd_flag = 1;
  198. break;
  199. case "3": // 待财务审核
  200. _params.arg_cp_flag = 1;
  201. _params.arg_flag = 0;
  202. break;
  203. case "4": // 已财务审核
  204. _params.arg_flag = 1;
  205. break;
  206. default:
  207. break;
  208. }
  209. newParams.queryParams = _params;
  210. newParams.dsname = "web_mattress";
  211. return CommonDynamicSelect(newParams, DwnameEnum.mattressQuote);
  212. // return [];
  213. };
  214. const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  215. if (globalStore.detailBlank) {
  216. // 打开新的窗口
  217. const routeUrl = router.resolve({
  218. path: `/mattressQuote/detail`,
  219. query: {
  220. id: row.mattressid,
  221. code: row.mattresscode
  222. }
  223. });
  224. window.open(routeUrl.href, "_blank");
  225. } else {
  226. // if (currentLayout.value.right.hidden && globalStore.mxFloat?.includes("custCrmDetail")) {
  227. // // 弹窗
  228. // mainData.value = row;
  229. // LjDrawerRef.value.show();
  230. // } else {
  231. // 打开新的标签页
  232. router.push(`/mattressQuote/detail?id=${row.mattressid}&code=${row.mattresscode}`);
  233. // }
  234. }
  235. };
  236. const handleClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
  237. if (ifShowDrawer.value) {
  238. funcShowQuoteList(row);
  239. }
  240. if (ifShowHisprice.value) {
  241. gotoHisprice(row.mattresscode, 0, { id: row.mattressid, typeid: 1 }, () => {
  242. ifShowHisprice.value = false;
  243. });
  244. }
  245. };
  246. /**
  247. * @description 记录当前行数据
  248. */
  249. const currentRecord = reactive<any>({});
  250. const funcShowQuoteList = (curRecord: any) => {
  251. loadingStatus.showQd = !loadingStatus.showQd;
  252. GetComputeMattressById({
  253. mattressid: curRecord.mattressid,
  254. check_original: Number(isShowOriginFormulaMattress.value)
  255. })
  256. .then(res => {
  257. const isQuoteListMxData = getQuoteListMxData(funcChaifenTabPro(res.mattress, res.mattressMx));
  258. currentRecord.data = res.mattress;
  259. currentRecord.mxdata = isQuoteListMxData;
  260. currentRecord.enumMap = vxeTableRef.value.enumMap;
  261. currentRecord.fabricMx = fabricMxTabList.value;
  262. currentRecord.formulakindenum = formulaKindEnum.value;
  263. currentRecord.dannum_type = res.mattress.dannum_type;
  264. currentRecord.formula = res.formulas;
  265. currentRecord.replace = res.replace;
  266. currentRecord.formula_ori = res.formulas_origin;
  267. currentRecord.formula_bednet = res.formulas_bednet;
  268. currentRecord.differ = res.differ;
  269. QuoteListDrawerRef.value.show(currentRecord);
  270. ifShowDrawer.value = true;
  271. loadingStatus.showQd = !loadingStatus.showQd;
  272. })
  273. .catch(err => {
  274. loadingStatus.showQd = !loadingStatus.showQd;
  275. });
  276. };
  277. const handleExportQuote = async (ifExpandAll: any, ifShowOrigin: any, fields: any) => {
  278. console.log("handleExportQuote ifExpandAll :>> ", ifExpandAll, ifShowOrigin);
  279. if (ifShowOrigin) {
  280. loadingStatus.download = true;
  281. await toExcelQuote(currentRecord, "床垫报价单_" + currentRecord.data.mattresscode);
  282. loadingStatus.download = false;
  283. } else {
  284. loadingStatus.download = true;
  285. currentRecord.fields = fields;
  286. await toExcelQuoteNew(currentRecord, "床垫报价单_" + currentRecord.data.mattresscode, ifExpandAll);
  287. loadingStatus.download = false;
  288. }
  289. };
  290. const rowClsNameFunc = (data: any) => {
  291. const { row, rowIndex, $rowIndex } = data;
  292. if (Number(row.flag) == 0) {
  293. if (Number(row.xd_flag) == 0) {
  294. return "vxecol-danger";
  295. }
  296. if (Number(row.xd_flag) == 1) {
  297. return "vxecol-blue";
  298. }
  299. }
  300. return "";
  301. };
  302. const tableProps = {
  303. height: "auto",
  304. editConfig: { trigger: "click", mode: "cell" },
  305. rowClassName: rowClsNameFunc,
  306. exportConfig: {
  307. filename: t("menu.rpMsttake") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
  308. },
  309. treeConfig: {
  310. expandAll: true,
  311. transform: true,
  312. rowField: "mattressid",
  313. parentField: "parentid"
  314. },
  315. checkboxConfig: {
  316. showHeader: true,
  317. checkStrictly: true
  318. }
  319. };
  320. // 返回绑定的事件
  321. const tableEvents = {
  322. // "checkbox-change": handleCheckboxChange,
  323. // "checkbox-all": handleCheckboxChange,
  324. // "checkbox-range-change": handleCheckboxChange,
  325. // "current-change": handleCurrentChanged
  326. "cell-dblclick": handleDBlClickTable,
  327. "cell-click": handleClickTable
  328. };
  329. onMounted(() => {
  330. dialogVisible.value = true;
  331. getFormulakindEnum();
  332. });
  333. /**
  334. * @description 业务下单或财务审核操作
  335. * @param params 对象,入参
  336. */
  337. const toAuditing = (params: any, message: string) => {
  338. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  339. console.log("curRecords :>> ", curRecords);
  340. if (!curRecords.length) {
  341. ElMessage.warning(t("business.tips.mattress.records"));
  342. return;
  343. }
  344. curRecords.map(o => {
  345. if (params.hasOwnProperty("xd_flag")) {
  346. if (o.js1_flag == 1) {
  347. ElMessage.warning("已产品补充审核,无法修改");
  348. return;
  349. }
  350. }
  351. });
  352. let _mattressids = curRecords.map((item: any) => Number(item.mattressid));
  353. ElMessageBox.confirm(`是否确定要对${curRecords.length}张床垫报价单进行操作`, "询问", {
  354. confirmButtonText: message,
  355. cancelButtonText: "否",
  356. type: "warning"
  357. })
  358. .then(() => {
  359. let _params = {
  360. ...params,
  361. mattressids: _mattressids
  362. };
  363. SaveMattressAuditing(_params).then(() => {
  364. ElMessage.success(t("sys.api.operationSuccess"));
  365. vxeTableRef.value.refresh();
  366. });
  367. })
  368. .catch((e: TypeError) => {
  369. ElMessage({
  370. type: "info",
  371. message: "操作取消"
  372. });
  373. });
  374. };
  375. /**
  376. * @description 按钮展示
  377. */
  378. const action: detailAction[] = [
  379. buttonDefault({
  380. label: t("common.redo"),
  381. clickFunc: item => {
  382. vxeTableRef.value.refresh();
  383. }
  384. }),
  385. buttonDefault({
  386. label: t("common.add"),
  387. power: 72,
  388. clickFunc: item => {
  389. console.log("inewss nitParams.value :>> ", vxeTableRef.value.searchParam);
  390. let _deptid = 0;
  391. if (Object.keys(vxeTableRef.value.searchParam).includes("arg_deptid")) {
  392. _deptid = vxeTableRef.value.searchParam.arg_deptid ?? 0;
  393. }
  394. if (_deptid == 0) {
  395. let enumMap = vxeTableRef.value.enumMap;
  396. let enumdata = enumMap.get("deptid");
  397. if (enumdata && enumdata.length > 0) {
  398. _deptid = enumdata[0].value;
  399. }
  400. }
  401. router.push(`/mattressQuote/new?id=0&deptid=${_deptid}`);
  402. }
  403. }),
  404. buttonDefault({
  405. label: t("common.editText"),
  406. power: 72,
  407. clickFunc: item => {
  408. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  409. if (!curRecords.length) {
  410. ElMessage.warning(t("business.tips.mattress.records"));
  411. return;
  412. }
  413. const _cur = curRecords[curRecords.length - 1];
  414. console.log("修改 _cur :>> ", _cur);
  415. if (_cur.parentid > 0) {
  416. ElMessage.warning("副规格无法编辑");
  417. return;
  418. }
  419. if (_cur.xd_flag == 1) {
  420. ElMessage.warning("已业务下单,不能修改");
  421. return;
  422. }
  423. if (_cur.flag == 1) {
  424. ElMessage.warning("单据已财核,不能修改");
  425. return;
  426. }
  427. pageCheckOpen(
  428. `/mattressQuote/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}`,
  429. "MattressQuote",
  430. _cur.mattressid,
  431. _cur.mattresscode
  432. );
  433. // router.push(`/mattressQuote/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}`);
  434. }
  435. }),
  436. buttonDefault({
  437. label: t("common.delText"),
  438. power: 77,
  439. disabledTextCallBack: (data: any) => {
  440. if (!CheckPower(77)) {
  441. return "你没有【报价单-删除】的使用权限";
  442. }
  443. return "";
  444. },
  445. clickFunc: item => {
  446. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  447. console.log("curRecords :>> ", curRecords);
  448. if (!curRecords.length) {
  449. ElMessage.warning(t("business.tips.mattress.records"));
  450. return;
  451. }
  452. try {
  453. curRecords.map(item => {
  454. if (item.createby !== userInfo.username && userInfo.empid != 0) {
  455. throw new Error("只能删除自己创建的报价单");
  456. }
  457. if (item.xd_flag == 1) {
  458. throw new Error("已业务下单,不能删除");
  459. }
  460. if (item.flag == 1) {
  461. throw new Error("单据已财核,不能删除");
  462. }
  463. });
  464. } catch (error) {
  465. ElMessage.error(error.message);
  466. return false;
  467. }
  468. let _mattressids = curRecords.map((item: any) => Number(item.mattressid));
  469. ElMessageBox.confirm(`是否确定要删除${curRecords.length}张床垫报价单(及其副规格报价单)吗?`, "询问", {
  470. confirmButtonText: t("common.delText"),
  471. cancelButtonText: "否",
  472. type: "warning"
  473. })
  474. .then(() => {
  475. DelMattress({ mattressids: _mattressids }).then(() => {
  476. ElMessage.success("删除成功!");
  477. vxeTableRef.value.refresh();
  478. });
  479. })
  480. .catch((e: TypeError) => {
  481. console.log("e :>> ", e);
  482. ElMessage({
  483. type: "info",
  484. message: "操作取消"
  485. });
  486. });
  487. }
  488. }),
  489. buttonDefault({
  490. label: t("common.copyQuote"),
  491. power: 75,
  492. clickFunc: item => {
  493. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  494. if (!curRecords.length) {
  495. ElMessage.warning(t("business.tips.mattress.records"));
  496. return;
  497. }
  498. let _cur = $table.getCurrentRecord() ?? null;
  499. if (!_cur) {
  500. _cur = curRecords[curRecords.length - 1];
  501. }
  502. router.push(`/mattressQuote/copy?id=${_cur.mattressid}&code=${_cur.mattresscode}`);
  503. }
  504. }),
  505. // [
  506. buttonDefault({
  507. label: t("common.businessOrder"),
  508. power: 94,
  509. clickFunc: item => {
  510. toAuditing({ xd_flag: 1 }, t("common.businessOrder"));
  511. }
  512. }),
  513. buttonDefault({
  514. label: t("common.businessOrderCancel"),
  515. power: 95,
  516. clickFunc: item => {
  517. toAuditing({ xd_flag: 0 }, t("common.businessOrderCancel"));
  518. }
  519. }),
  520. // ],
  521. // [
  522. buttonDefault({
  523. label: t("common.auditFinance"),
  524. power: 73,
  525. clickFunc: item => {
  526. toAuditing({ flag: 1 }, t("common.auditFinance"));
  527. }
  528. }),
  529. buttonDefault({
  530. label: t("common.withdrawAuditFinance"),
  531. power: 74,
  532. clickFunc: item => {
  533. toAuditing({ flag: 0 }, t("common.withdrawAuditFinance"));
  534. }
  535. }),
  536. // ],
  537. buttonDefault({
  538. label: t("common.copyFromMulitFlag"),
  539. power: 75,
  540. clickFunc: async item => {
  541. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  542. console.log("curRecords :>> ", curRecords);
  543. if (!curRecords.length) {
  544. ElMessage.warning(t("business.tips.mattress.records"));
  545. return;
  546. }
  547. await openDeptChoosen(curRecords);
  548. }
  549. }),
  550. // buttonDefault({
  551. // label: t("common.recalculateFromNotFlag"),
  552. // power: 72,
  553. // clickFunc: item => {
  554. // const { curRecords } = getCurrentRecords(vxeTableRef.value);
  555. // console.log("curRecords :>> ", curRecords);
  556. // if (!curRecords.length) {
  557. // ElMessage.warning(t("business.tips.mattress.records"));
  558. // return;
  559. // }
  560. // let list = curRecords.map((item: any) => {
  561. // return { mattressid: Number(item.mattressid) };
  562. // });
  563. // ElMessageBox.confirm(`是否确定要批重算${curRecords.length}张床垫报价单吗?`, "询问", {
  564. // confirmButtonText: t("common.okText"),
  565. // cancelButtonText: "否",
  566. // type: "warning"
  567. // })
  568. // .then(() => {
  569. // ReCalculateNoAudit({ list }).then(() => {
  570. // ElMessage.success("批重算成功!");
  571. // vxeTableRef.value.refresh();
  572. // });
  573. // })
  574. // .catch((e: TypeError) => {
  575. // console.log("e :>> ", e);
  576. // ElMessage({
  577. // type: "info",
  578. // message: "操作取消"
  579. // });
  580. // });
  581. // }
  582. // }),
  583. buttonDefault({
  584. label: t("common.viewHistoricalQuotes"),
  585. power: 72,
  586. clickFunc: item => {
  587. const curRecord = vxeTableRef.value.element.getCurrentRecord() ?? null;
  588. // console.log("curRecords :>> ", curRecords);
  589. if (!curRecord) {
  590. ElMessage.warning(t("business.tips.mattress.records"));
  591. return;
  592. // } else if (curRecords.length > 1) {
  593. // ElMessage.warning(`无法进行多单${t("common.showQuoteList")}`);
  594. // return;
  595. }
  596. ifShowHisprice.value = true;
  597. gotoHisprice(curRecord.mattresscode, 0, { id: curRecord.mattressid, typeid: 1 }, () => {
  598. ifShowHisprice.value = false;
  599. });
  600. }
  601. }),
  602. buttonDefault({
  603. label: t("common.showQuoteList"),
  604. loading: () => loadingStatus.showQd,
  605. power: 72,
  606. clickFunc: async item => {
  607. // const { curRecords } = getCurrentRecords(vxeTableRef.value);
  608. const curRecord = vxeTableRef.value.element.getCurrentRecord() ?? null;
  609. // console.log("curRecords :>> ", curRecords);
  610. if (!curRecord) {
  611. ElMessage.warning(t("business.tips.mattress.records"));
  612. return;
  613. // } else if (curRecords.length > 1) {
  614. // ElMessage.warning(`无法进行多单${t("common.showQuoteList")}`);
  615. // return;
  616. }
  617. funcShowQuoteList(curRecord);
  618. }
  619. }),
  620. buttonDefault({
  621. label: t("common.dataTransmission"),
  622. power: 72,
  623. clickFunc: item => {
  624. // alert("功能维护中!");
  625. const { $table } = getCurrentRecords(vxeTableRef.value);
  626. const now = new Date();
  627. $table?.openExport({ filename: `床垫报价_${formatTime(now, "{y}-{m}-{d}", false)}` });
  628. }
  629. }),
  630. buttonDefault({
  631. label: t("common.businessSupplement"),
  632. power: 72,
  633. clickFunc: item => {
  634. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  635. if (!curRecords.length) {
  636. ElMessage.warning(t("business.tips.mattress.records"));
  637. return;
  638. }
  639. let _cur = $table.getCurrentRecord() ?? curRecords[curRecords.length - 1];
  640. let type = 1;
  641. // router.push(`/erpapi/mattressInterface/${type}/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}&type=${type}`);
  642. gotoErpapi(_cur, type);
  643. }
  644. }),
  645. buttonDefault({
  646. label: t("common.recalculateERPCost"),
  647. power: 72,
  648. clickFunc: async item => {
  649. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  650. console.log("curRecords :>> ", curRecords);
  651. if (!curRecords.length) {
  652. ElMessage.warning(t("business.tips.mattress.records"));
  653. return;
  654. }
  655. let list = curRecords.map((item: any) => {
  656. return { mattressid: Number(item.mattressid) };
  657. });
  658. ElMessageBox.confirm(`是否确定要批重算${curRecords.length}张床垫报价单吗?`, "询问", {
  659. confirmButtonText: t("common.okText"),
  660. cancelButtonText: "否",
  661. type: "warning"
  662. })
  663. .then(() => {
  664. ReCalculateERPCost({ list }).then((res: any) => {
  665. ElMessage.success(res.logMsg);
  666. vxeTableRef.value.refresh();
  667. });
  668. })
  669. .catch((e: TypeError) => {
  670. ElMessage({
  671. type: "info",
  672. message: "操作取消"
  673. });
  674. });
  675. }
  676. }),
  677. buttonDefault({
  678. label: t("common.viewBusinessSupplement"),
  679. power: 72,
  680. clickFunc: item => {
  681. const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
  682. if (!curRecords.length) {
  683. ElMessage.warning(t("business.tips.mattress.records"));
  684. return;
  685. }
  686. let _cur = $table.getCurrentRecord() ?? curRecords[curRecords.length - 1];
  687. router.push({
  688. name: "mattressInterfaceDetail",
  689. params: {
  690. id: _cur.mattressid
  691. },
  692. query: {
  693. code: _cur.mattresscode
  694. },
  695. replace: true
  696. });
  697. }
  698. })
  699. ];
  700. const openDeptChoosen = async curRecords => {
  701. try {
  702. // let newParams = {
  703. // dsname: "_Mapper_deptid",
  704. // queryparams: {}
  705. // };
  706. // let res = await CommonDynamicSelect(newParams);
  707. // if (res.datatable) {
  708. // deptEnum.value = res.datatable?.map((item: any) => {
  709. // return { label: item.deptname, value: item.deptid };
  710. // });
  711. // }
  712. let res = await getUserList({ simple: 1 });
  713. console.log("pricelist res :>> ", res);
  714. userListData.value = res.userList;
  715. let enumMap = vxeTableRef.value.enumMap;
  716. deptEnum.value = enumMap.get("deptid");
  717. console.log("openDeptChoosen deptEnum.value :>> ", deptEnum.value);
  718. console.log("openDeptChoosen curRecords.value :>> ", curRecords);
  719. if (deptEnum.value.length > 0) {
  720. formParam.value.deptid = curRecords[0].deptid;
  721. formParam.value.packtype = curRecords[0].packtype;
  722. formParam.value.packqty = curRecords[0].packqty;
  723. formParam.value.commission = curRecords[0].commission;
  724. formParam.value.other_rate = curRecords[0].other_rate;
  725. formParam.value.extras_cost = curRecords[0].extras_cost;
  726. formParam.value.moneytype = curRecords[0].moneyrate > 1 ? 1 : 0;
  727. dialogFormVisible.value = true;
  728. } else {
  729. console.error("获取部门列表为空");
  730. }
  731. } catch (error) {
  732. console.error("获取部门列表失败", error);
  733. }
  734. };
  735. const BatchCopyMattressAudited = () => {
  736. const { curRecords } = getCurrentRecords(vxeTableRef.value);
  737. console.log("curRecords :>> ", curRecords);
  738. if (!curRecords.length) {
  739. ElMessage.warning(t("business.tips.mattress.records"));
  740. return;
  741. }
  742. loadingBtn.value = true;
  743. let list = curRecords.map((item: any) => {
  744. const result = {
  745. mattressid: Number(item.mattressid),
  746. deptid: formParam.value.deptid,
  747. area: formParam.value.area,
  748. cabinet_type: formParam.value.cabinet_type,
  749. packtype: formParam.value.packtype,
  750. packqty: formParam.value.packqty,
  751. createby: formParam.value.createby,
  752. commission: formParam.value.commission,
  753. taxes: formParam.value.taxes,
  754. other_rate: formParam.value.other_rate,
  755. extras_cost: formParam.value.extras_cost,
  756. moneyrate: formParam.value.moneyrate,
  757. discount: formParam.value.discount
  758. };
  759. return result;
  760. });
  761. ElMessageBox.confirm(`是否确定要批复制${curRecords.length}张床垫报价单吗?`, "询问", {
  762. confirmButtonText: t("common.okText"),
  763. cancelButtonText: "否",
  764. type: "warning"
  765. })
  766. .then(() => {
  767. CopyMattressAudited({ list }).then(() => {
  768. ElMessage.success("复制成功!");
  769. dialogFormVisible.value = false;
  770. vxeTableRef.value.refresh();
  771. loadingBtn.value = false;
  772. });
  773. })
  774. .catch((e: TypeError) => {
  775. console.log("e :>> ", e);
  776. ElMessage({
  777. type: "info",
  778. message: "操作取消"
  779. });
  780. loadingBtn.value = false;
  781. });
  782. };
  783. /**
  784. * @description 监听框架属性变化
  785. */
  786. mittBus.on(MittEnum.MattressList, () => {
  787. vxeTableRef.value.refresh();
  788. });
  789. const autoUpdateTableCheckbox = () => {
  790. const $table = vxeTableRef.value.element;
  791. if ($table) {
  792. $table.setAllTreeExpand(true);
  793. }
  794. };
  795. const wf_get_moneyrate_discount = val => {
  796. let depItem = deptEnum.value.find((item: any) => item.value == formParam.value.deptid);
  797. if (depItem) {
  798. let _moneyrate = !depItem.moneyrate || Number(depItem.moneyrate) == 0 ? 1 : depItem.moneyrate;
  799. if (formParam.value.moneytype == 0) {
  800. formParam.value.moneyrate = 1;
  801. } else {
  802. formParam.value.moneyrate = _moneyrate;
  803. }
  804. formParam.value.discount = depItem.discount;
  805. }
  806. };
  807. </script>
  808. <style lang="scss">
  809. .select-text-right {
  810. .el-select__wrapper {
  811. text-align: right;
  812. }
  813. }
  814. </style>