|
@@ -1,12 +1,14 @@
|
|
|
import { ref, reactive, computed, toRefs, nextTick } from "vue";
|
|
|
import { ColumnProps } from "@/components/LjVxeTable/interface";
|
|
|
-import { GetSoftBedMxList } from "@/api/modules/quote";
|
|
|
+import { GetSoftBedMxList, SaveSoftBedQuote } from "@/api/modules/quote";
|
|
|
import { ALLOW_EDIT_STATE } from "@/config/index";
|
|
|
-import { ElButton, ElMessage, ElMessageBox, ElRow, ElCol } from "element-plus";
|
|
|
+import { ElButton, ElMessage, ElMessageBox, ElRow, ElCol, ElNotification } from "element-plus";
|
|
|
import { AuditSoftBedQuote, DeleteSoftBedQuote } from "@/api/modules/quote";
|
|
|
import { getDeptList } from "@/api/modules/saleprice";
|
|
|
import { CommonDynamicSelect } from "@/api/modules/common";
|
|
|
import SoftBedSelect from "@/views/system/selector/softbedTemplate/select.vue";
|
|
|
+import { cloneDeep } from "lodash-es";
|
|
|
+import { getCurrentRecords } from "@/utils/index";
|
|
|
interface defaultState {
|
|
|
/**
|
|
|
* @description 单据当前状态
|
|
@@ -23,7 +25,18 @@ interface defaultState {
|
|
|
/**
|
|
|
* @description 详情页明细表格Ref
|
|
|
*/
|
|
|
- VxeTableMxRef: any;
|
|
|
+ VxeTableHeadBoardMxRef: any;
|
|
|
+ /**
|
|
|
+ * @description 详情页明细表格Ref
|
|
|
+ */
|
|
|
+ VxeTableNightStandMxRef: any;
|
|
|
+ /**
|
|
|
+ * @description 详情页明细表格Ref
|
|
|
+ */
|
|
|
+ VxeTableBedFrameMxRef: any;
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
initParams: any;
|
|
|
/**
|
|
|
* @description 详情页主表数据
|
|
@@ -45,6 +58,30 @@ interface defaultState {
|
|
|
* @description 详情页主表明细数据-床架
|
|
|
*/
|
|
|
bedFrameMx: any[];
|
|
|
+ /**
|
|
|
+ * @description 详情页模板报价弹窗对象
|
|
|
+ */
|
|
|
+ SoftBedTemplateDialogRef: any;
|
|
|
+ /**
|
|
|
+ * @description 详情页模板报价弹窗入参
|
|
|
+ */
|
|
|
+ SoftBedTemplateDialogProps: any;
|
|
|
+ /**
|
|
|
+ * @description 详情页部件配置选择弹窗
|
|
|
+ */
|
|
|
+ isModalVisible: boolean;
|
|
|
+ /**
|
|
|
+ * @description 详情页部件配置选择弹窗
|
|
|
+ */
|
|
|
+ showHeadboard: boolean;
|
|
|
+ /**
|
|
|
+ * @description 详情页部件配置选择弹窗
|
|
|
+ */
|
|
|
+ showNightstand: boolean;
|
|
|
+ /**
|
|
|
+ * @description 详情页部件配置选择弹窗
|
|
|
+ */
|
|
|
+ showBedframe: boolean;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -56,12 +93,20 @@ export const useHooks = (t?: any) => {
|
|
|
orderStatus: "",
|
|
|
VxeTableRef: null,
|
|
|
LjDetailRef: null,
|
|
|
- VxeTableMxRef: null,
|
|
|
- softBed: null,
|
|
|
- softBedMx: null,
|
|
|
- headBoardMx: null,
|
|
|
- nightStandMx: null,
|
|
|
- bedFrameMx: null,
|
|
|
+ VxeTableHeadBoardMxRef: null,
|
|
|
+ VxeTableBedFrameMxRef: null,
|
|
|
+ VxeTableNightStandMxRef: null,
|
|
|
+ softBed: {},
|
|
|
+ softBedMx: [],
|
|
|
+ headBoardMx: [],
|
|
|
+ nightStandMx: [],
|
|
|
+ bedFrameMx: [],
|
|
|
+ SoftBedTemplateDialogRef: null,
|
|
|
+ SoftBedTemplateDialogProps: null,
|
|
|
+ isModalVisible: false,
|
|
|
+ showHeadboard: false,
|
|
|
+ showNightstand: false,
|
|
|
+ showBedframe: false,
|
|
|
initParams: { arg_softbed_id: 0 }
|
|
|
});
|
|
|
// 表格配置项
|
|
@@ -91,9 +136,11 @@ export const useHooks = (t?: any) => {
|
|
|
title: "部门",
|
|
|
enum: () =>
|
|
|
getDeptList({}).then(res => {
|
|
|
- return res.datatable;
|
|
|
+ return res.datatable.map(t => {
|
|
|
+ return { ...t, label: t.deptname, value: t.deptid };
|
|
|
+ });
|
|
|
}),
|
|
|
- fieldNames: { label: "deptname", value: "deptid" },
|
|
|
+ // fieldNames: { label: "deptname", value: "deptid" },
|
|
|
search: {
|
|
|
el: "select",
|
|
|
key: "arg_deptid",
|
|
@@ -133,6 +180,10 @@ export const useHooks = (t?: any) => {
|
|
|
datatype: "checkbox",
|
|
|
basicinfo: {
|
|
|
el: "checkbox",
|
|
|
+ props: {
|
|
|
+ trueValue: 1,
|
|
|
+ falseValue: 0
|
|
|
+ },
|
|
|
span: 1,
|
|
|
row: 1,
|
|
|
order: 2,
|
|
@@ -154,15 +205,35 @@ export const useHooks = (t?: any) => {
|
|
|
field: "template_code",
|
|
|
title: "模板编号",
|
|
|
basicinfo: {
|
|
|
+ el: "select",
|
|
|
span: 1,
|
|
|
row: 1,
|
|
|
order: 4,
|
|
|
group: "单据信息",
|
|
|
- editable: (scope: any) => {
|
|
|
- if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.is_template)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+ render: (scope: any) => {
|
|
|
+ const { column, searchParam: row, status } = scope;
|
|
|
+ let params = {
|
|
|
+ arg_template_id: row.template_id
|
|
|
+ };
|
|
|
+ let _disabled = !(ALLOW_EDIT_STATE.includes(state.orderStatus) && !Number(scope.searchParam.is_template));
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <SoftBedSelect
|
|
|
+ value={row.template_code}
|
|
|
+ {...params}
|
|
|
+ clearable
|
|
|
+ disabled={_disabled}
|
|
|
+ placeholder={row.template_code}
|
|
|
+ onOpenModal={() => fModelChoseTemplate(row, params)}
|
|
|
+ onSelect={(val: any) => rModelSetTemplate(row, val)}
|
|
|
+ onClear={() => rModelClearTemplate(row)}
|
|
|
+ >
|
|
|
+ {{
|
|
|
+ label: () => row.template_code
|
|
|
+ }}
|
|
|
+ </SoftBedSelect>
|
|
|
+ </>
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -171,23 +242,24 @@ export const useHooks = (t?: any) => {
|
|
|
title: "报价名称",
|
|
|
basicinfo: {
|
|
|
el: "input",
|
|
|
+ editable: ALLOW_EDIT_STATE,
|
|
|
span: 1,
|
|
|
row: 1,
|
|
|
order: 5,
|
|
|
- group: "单据信息",
|
|
|
- editable: ALLOW_EDIT_STATE
|
|
|
+ group: "单据信息"
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
field: "template_name",
|
|
|
title: "模板名称",
|
|
|
basicinfo: {
|
|
|
+ el: "input",
|
|
|
span: 1,
|
|
|
row: 1,
|
|
|
order: 6,
|
|
|
group: "单据信息",
|
|
|
editable: (scope: any) => {
|
|
|
- if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.is_template)) {
|
|
|
+ if (ALLOW_EDIT_STATE.includes(scope.status) && !Number(scope.searchParam.is_template)) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
@@ -199,11 +271,11 @@ export const useHooks = (t?: any) => {
|
|
|
title: "报价编码",
|
|
|
basicinfo: {
|
|
|
el: "input",
|
|
|
+ editable: ALLOW_EDIT_STATE,
|
|
|
span: 1,
|
|
|
row: 1,
|
|
|
order: 7,
|
|
|
- group: "单据信息",
|
|
|
- editable: ALLOW_EDIT_STATE
|
|
|
+ group: "单据信息"
|
|
|
}
|
|
|
},
|
|
|
{
|
|
@@ -449,7 +521,7 @@ export const useHooks = (t?: any) => {
|
|
|
|
|
|
return (
|
|
|
<el-select
|
|
|
- v-model={scope.searchParam.if_moneyrate}
|
|
|
+ v-model={scope.searchParam.money_type}
|
|
|
v-slots={slotprefix}
|
|
|
class="select-text-right"
|
|
|
disabled={_disabled}
|
|
@@ -779,34 +851,90 @@ export const useHooks = (t?: any) => {
|
|
|
*/
|
|
|
const detail_getData = async (params: any) => {
|
|
|
const result = await GetSoftBedMxList(params);
|
|
|
- detail_dataCallback(result);
|
|
|
- };
|
|
|
-
|
|
|
- const detail_dataCallback = (data: any) => {
|
|
|
if (state.orderStatus === "new") {
|
|
|
- data.softbed.taxrate = 1;
|
|
|
+ result.softbed.taxrate = 1;
|
|
|
}
|
|
|
|
|
|
- state.softBed = [data.softbed];
|
|
|
- state.softBedMx = data.mxList;
|
|
|
- state.headBoardMx = data.mxList.filter(item => item.has_type === 1);
|
|
|
- state.nightStandMx = data.mxList.filter(item => item.has_type === 2);
|
|
|
- state.bedFrameMx = data.mxList.filter(item => item.has_type === 4);
|
|
|
+ state.softBed = [result.softbed];
|
|
|
+ state.softBedMx = result.mxList;
|
|
|
+ state.headBoardMx = result.mxList.filter(item => item.has_type === 1);
|
|
|
+ state.nightStandMx = result.mxList.filter(item => item.has_type === 2);
|
|
|
+ state.bedFrameMx = result.mxList.filter(item => item.has_type === 4);
|
|
|
};
|
|
|
-
|
|
|
/**
|
|
|
* 打开部件配置弹窗
|
|
|
*/
|
|
|
- const onOpenConfigureDialog = () => {};
|
|
|
+ const onOpenConfigureDialog = () => {
|
|
|
+ const { _mainData, enumMap } = state.LjDetailRef;
|
|
|
+ nextTick(() => {
|
|
|
+ state.showHeadboard = Boolean(_mainData.has_headboard);
|
|
|
+ state.showNightstand = Boolean(_mainData.has_nightstand);
|
|
|
+ state.showBedframe = Boolean(_mainData.has_bedframe);
|
|
|
+
|
|
|
+ state.isModalVisible = true;
|
|
|
+ });
|
|
|
+ };
|
|
|
/**
|
|
|
* 确认部件配置项值
|
|
|
* @param params 返回内容
|
|
|
*/
|
|
|
- const onConfirmConfigureDialog = (params: any) => {};
|
|
|
+ const onConfirmConfigureDialog = (params: any) => {
|
|
|
+ const { _mainData } = state.LjDetailRef;
|
|
|
+ nextTick(() => {
|
|
|
+ _mainData.has_headboard = Number(state.showHeadboard);
|
|
|
+ _mainData.has_nightstand = Number(state.showNightstand);
|
|
|
+ _mainData.has_bedframe = Number(state.showBedframe);
|
|
|
+
|
|
|
+ state.isModalVisible = false;
|
|
|
+ });
|
|
|
+ };
|
|
|
/**
|
|
|
* 保存报价
|
|
|
*/
|
|
|
- const onSave = () => {};
|
|
|
+ const onSave = async cb => {
|
|
|
+ const { _mainData } = state.LjDetailRef;
|
|
|
+ const headboard_table = state.VxeTableHeadBoardMxRef.element.getTableData();
|
|
|
+ const nightstand_table = state.VxeTableNightStandMxRef.element.getTableData();
|
|
|
+ const bedframe_table = state.VxeTableBedFrameMxRef.element.getTableData();
|
|
|
+
|
|
|
+ const _softbed = cloneDeep(_mainData);
|
|
|
+ const _mxList = [];
|
|
|
+ _softbed.mxList = _mxList;
|
|
|
+
|
|
|
+ if (headboard_table && headboard_table.length > 0) _mxList.push(headboard_table);
|
|
|
+ if (nightstand_table && nightstand_table.length > 0) _mxList.push(nightstand_table);
|
|
|
+ if (bedframe_table && bedframe_table.length > 0) _mxList.push(bedframe_table);
|
|
|
+
|
|
|
+ transformData(_softbed);
|
|
|
+
|
|
|
+ const params: any = {
|
|
|
+ softbed: _softbed
|
|
|
+ };
|
|
|
+
|
|
|
+ try {
|
|
|
+ await SaveSoftBedQuote(params)
|
|
|
+ .then((res: any) => {
|
|
|
+ ElNotification({
|
|
|
+ title: "温馨提示",
|
|
|
+ message: t("sys.api.sueccessToSave"),
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+
|
|
|
+ cb && cb(res);
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.log("error !! :>> ", error);
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ ElMessage.error(t("sys.api.operationFailed"));
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const transformData = (data: any) => {
|
|
|
+ for (let key in data) {
|
|
|
+ if (typeof data[key] === "boolean") data[key] = Number(data[key]);
|
|
|
+ }
|
|
|
+ };
|
|
|
/**
|
|
|
* 审核报价
|
|
|
*/
|
|
@@ -819,7 +947,7 @@ export const useHooks = (t?: any) => {
|
|
|
.then(() => {
|
|
|
AuditSoftBedQuote({ list, type: 1 }).then(() => {
|
|
|
ElMessage.success(t("sys.api.operationSuccess"));
|
|
|
- state.VxeTableMxRef.refresh();
|
|
|
+ state.VxeTableRef.refresh();
|
|
|
});
|
|
|
})
|
|
|
.catch((e: TypeError) => {
|
|
@@ -841,7 +969,7 @@ export const useHooks = (t?: any) => {
|
|
|
.then(() => {
|
|
|
AuditSoftBedQuote({ list, type: 0 }).then(() => {
|
|
|
ElMessage.success(t("sys.api.operationSuccess"));
|
|
|
- state.VxeTableMxRef.refresh();
|
|
|
+ state.VxeTableRef.refresh();
|
|
|
});
|
|
|
})
|
|
|
.catch((e: TypeError) => {
|
|
@@ -864,7 +992,7 @@ export const useHooks = (t?: any) => {
|
|
|
DeleteSoftBedQuote({ list }).then(() => {
|
|
|
ElMessage.success(t("sys.api.operationSuccess"));
|
|
|
cb && cb();
|
|
|
- state.VxeTableMxRef.refresh();
|
|
|
+ state.VxeTableRef.refresh();
|
|
|
});
|
|
|
})
|
|
|
.catch((e: TypeError) => {
|
|
@@ -898,8 +1026,8 @@ export const useHooks = (t?: any) => {
|
|
|
let depItem = deptEnum.find((item: any) => item.deptid == _mainData.deptid);
|
|
|
if (depItem) {
|
|
|
let _moneyrate = !depItem.moneyrate || Number(depItem.moneyrate) == 0 ? 1 : depItem.moneyrate;
|
|
|
- if (val == 0 || !_mainData.if_moneyrate) {
|
|
|
- _mainData.if_moneyrate = 0;
|
|
|
+ if (val == 0 || !_mainData.money_type) {
|
|
|
+ _mainData.money_type = 0;
|
|
|
_mainData.moneyrate = 1;
|
|
|
} else {
|
|
|
_mainData.moneyrate = _moneyrate;
|
|
@@ -913,16 +1041,109 @@ export const useHooks = (t?: any) => {
|
|
|
data.taxrate = val;
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * @description 弹窗模块:客户选择
|
|
|
+ * @param data 当前数据
|
|
|
+ * @param status 当前订单状态
|
|
|
+ * @returns Promise
|
|
|
+ */
|
|
|
+ const fModelChoseTemplate = (data: any, params: any) => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ let _params = {
|
|
|
+ arg_search: ""
|
|
|
+ };
|
|
|
+ state.SoftBedTemplateDialogProps = {
|
|
|
+ onSubmit: (res: any) => {
|
|
|
+ // submit
|
|
|
+ nextTick(() => {
|
|
|
+ rModelSetTemplate(data, res.value[0]);
|
|
|
+ resolve(1);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onCancel: (error: any) => {
|
|
|
+ // cancel 回调
|
|
|
+ }
|
|
|
+ };
|
|
|
+ state.SoftBedTemplateDialogRef.show(_params);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * @description 数据赋值: 联系人
|
|
|
+ * @param data 当前数据
|
|
|
+ * @param item 当前选择的数据
|
|
|
+ */
|
|
|
+ const rModelSetTemplate = (data: any, item: any) => {
|
|
|
+ data.template_id = Number(item.softbed_id);
|
|
|
+ data.template_code = item.softbed_code;
|
|
|
+ data.template_name = item.softbed_name;
|
|
|
+ };
|
|
|
+ /**
|
|
|
+ * 清空选择参数
|
|
|
+ * @param data
|
|
|
+ */
|
|
|
+ const rModelClearTemplate = (data: any) => {
|
|
|
+ data.template_id = 0;
|
|
|
+ data.template_code = "";
|
|
|
+ data.template_name = "";
|
|
|
+ };
|
|
|
+
|
|
|
+ const toAddMx = async (tableRef: any) => {
|
|
|
+ const { _mainData } = state.LjDetailRef;
|
|
|
+ const $table = tableRef.element;
|
|
|
+ if ($table) {
|
|
|
+ // 新增
|
|
|
+ const records = {
|
|
|
+ softbed_id: _mainData.softbed_id,
|
|
|
+ has_type: getHasType(tableRef),
|
|
|
+ mtrlname: "",
|
|
|
+ mtrlcode: "",
|
|
|
+ mtrlmode: "",
|
|
|
+ unit: "",
|
|
|
+ allow_edit: 0,
|
|
|
+ cutting_length: 0,
|
|
|
+ cutting_width: 0,
|
|
|
+ cutting_qty: 0
|
|
|
+ };
|
|
|
+ const { row } = await $table.insertAt(records, -1);
|
|
|
+ await $table.setCurrentRow(row);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const toDelMx = (tableRef: any) => {
|
|
|
+ const { $table } = getCurrentRecords(tableRef);
|
|
|
+ ElMessageBox.confirm(`是否确定要删除明细吗?`, "询问", {
|
|
|
+ confirmButtonText: t("common.delText"),
|
|
|
+ cancelButtonText: "否",
|
|
|
+ type: "error"
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ $table.removeCurrentRow();
|
|
|
+ })
|
|
|
+ .catch((e: TypeError) => {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "操作取消"
|
|
|
+ });
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ const getHasType = (tableRef: any) => {
|
|
|
+ return tableRef === state.VxeTableHeadBoardMxRef ? 1 : tableRef === state.VxeTableNightStandMxRef ? 2 : 4;
|
|
|
+ };
|
|
|
+
|
|
|
return {
|
|
|
...toRefs(state),
|
|
|
columns,
|
|
|
columnsMx,
|
|
|
detail_getData,
|
|
|
+ toAddMx,
|
|
|
+ toDelMx,
|
|
|
onSave,
|
|
|
onAudit,
|
|
|
onCAudit,
|
|
|
onDelete,
|
|
|
onCopyQuote,
|
|
|
- onShowFormula
|
|
|
+ onShowFormula,
|
|
|
+ onConfirmConfigureDialog
|
|
|
};
|
|
|
};
|