소스 검색

1、新增软床报价模版选择
2、新增软床报价模板保存逻辑

iggy 17 시간 전
부모
커밋
a7d2b4aefb

+ 80 - 0
JLHHJSvr/DataStore/web_softbed_choose.xml

@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<select>
+  <selectstr>
+SELECT u_softbed.softbed_id
+	,u_softbed.softbed_code
+	,u_softbed.softbed_relcode
+	,u_softbed.softbed_name
+	,u_softbed.deptid
+	,u_softbed.create_date
+	,u_softbed.create_emp
+	,u_softbed.mtrlmode
+	,u_softbed.mtrltype
+	,u_softbed.has_headboard
+	,u_softbed.has_nightstand
+	,u_softbed.has_bedframe
+	,u_softbed.is_template
+	,u_softbed.template_id
+	,u_softbed.template_code
+	,u_softbed.template_name
+	,u_softbed.commission
+	,u_softbed.taxes
+	,u_softbed.other_rate
+	,u_softbed.extras_cost
+	,u_softbed.moneyrate
+	,u_softbed.dscrp
+	,u_softbed.costamt
+	,u_softbed.nottax_factory_cost
+	,u_softbed.nottax_dept_cost
+	,u_softbed.dept_cost
+	,u_softbed.foreign_cost
+	,u_softbed.flag
+	,u_softbed.audit_date
+	,u_softbed.audit_emp
+	,u_softbed.update_date
+	,u_softbed.update_emp
+FROM u_softbed
+  </selectstr>
+  <where>
+	<when>
+		u_softbed.is_template = 1
+	</when>
+	<when notnull="@arg_search">
+		u_softbed.softbed_code LIKE '%' + @arg_search + '%' OR u_softbed.softbed_name LIKE '%' + @arg_search + '%' OR u_softbed.softbed_relcode LIKE '%' + @arg_search + '%'
+	</when>
+  </where>
+  <orderstr>create_date DESC,softbed_id DESC</orderstr>
+  <displayfields>
+    <field field="pid" compute="getrow()">序</field>
+	<field field="softbed_code">报价唯一码</field>
+	<field field="softbed_name">报价编码</field>
+	<field field="softbed_name">报价名称</field>
+	<field field="deptid" mapper="">部门</field>
+	<field field="flag" datatype="checkbox">审核</field>
+	<field field="create_date" datatype="datetime">报价日期</field>
+	<field field="create_emp">报价人</field>
+	<field field="mtrlmode">物料规格</field>
+	<field field="mtrltype">物料类别</field>
+	<field field="has_headboard" datatype="checkbox">床头</field>
+	<field field="has_nightstand" datatype="checkbox">床头柜</field>
+	<field field="has_bedframe" datatype="checkbox">床架</field>
+	<field field="is_template" datatype="checkbox">模板报价</field>
+	<field field="template_code">模板编号</field>
+	<field field="template_name">模板名称</field>
+	<field field="commission" datatype="number">佣金</field>
+	<field field="taxes" datatype="number">税金</field>
+	<field field="other_rate" datatype="number">额外点数</field>
+	<field field="extras_cost" datatype="number">额外费用</field>
+	<field field="moneyrate" datatype="number" mapper="u_mattress.if_moneyrate">汇率</field>
+	<field field="dscrp">备注</field>
+	<field field="costamt" datatype="number">报价金额</field>
+	<field field="nottax_factory_cost" datatype="number">不含税出厂价</field>
+	<field field="nottax_dept_cost" datatype="number">部门售价(不含税)</field>
+	<field field="dept_cost" datatype="number">部门含税价</field>
+	<field field="foreign_cost" datatype="number">外币价</field>
+	<field field="audit_date" datatype="datetime">审核日期</field>
+	<field field="audit_emp">审核人</field>
+	<field field="update_date" datatype="datetime">更新日期</field>
+	<field field="update_emp">更新人</field>
+  </displayfields>
+</select>

+ 35 - 0
JLHHJSvr/Helper/BasicInfoHelper.cs

@@ -0,0 +1,35 @@
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com.Model;
+using LJLib.DAL.SQL;
+using NPOI.SS.Formula.Functions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JLHHJSvr.Helper
+{
+    internal class BasicInfoHelper: HelperBase
+    {
+        public void SaveConfigureType(u_configure_type configure)
+        {
+            if (configure.contfigtypeid <= 0)
+            {
+                configure.contfigtypeid = BllHelper.GetID(cmd, "u_configure_type");
+
+                var fields = @"contfigtypeid,contfigtype,contfigtypename,usechflag,flag";
+                DbSqlHelper.Insert(cmd, "u_configure_type", null, configure, fields);
+            }
+            else
+            {
+                configure.moddate = context.opdate;
+                configure.modemp = context.tokendata.username;
+
+                //修改
+                var fields = @"contfigtype,contfigtypename,usechflag,modemp,moddate";
+                DbSqlHelper.Update(cmd, "u_configure_type", null, configure, "contfigtypeid", fields);
+            }
+        }
+    }
+}

+ 64 - 1
JLHHJSvr/Helper/SoftBedHelper.cs

@@ -200,7 +200,7 @@ namespace JLHHJSvr.Helper
 		public void SaveSoftBed(u_softbed softbed)
 		{
 			if (softbed == null) throw new LJCommonException("软床报价保存失败,数据异常!");
-			if (softbed.mxList == null || softbed.mxList.Count <= 0) throw new LJCommonException("软床报价保存失败,明细内容为空!");
+			if (softbed.is_template == 0 && (softbed.mxList == null || softbed.mxList.Count <= 0)) throw new LJCommonException("软床报价保存失败,明细内容为空!");
 
 			// 初始化属性
 			AutoInit.AutoInitS(softbed);
@@ -261,8 +261,71 @@ namespace JLHHJSvr.Helper
 
 				DbSqlHelper.Insert(cmd, "u_softbed_mx", null, mx, mx_fields);
             }
+
+			SaveSoftBedTemplate(softbed);
         }
+		/// <summary>
+		/// 新建软床报价模板
+		/// </summary>
+		/// <param name="softbed"></param>
+		private void SaveSoftBedTemplate(u_softbed softbed)
+		{
+			if (softbed.is_template == 0) return;
+
+			if(string.IsNullOrEmpty(softbed.softbed_code))
+			{
+				throw new LJCommonException("报价未生成唯一码,无法生成模板配置");
+			}
+
+			string prefix = $"{softbed.softbed_code}|";
+			var configureList = new List<u_configure_type>();
+			if(softbed.has_headboard == 1)
+			{
+                configureList.Add(new u_configure_type()
+				{
+                    contfigtypename = $"{prefix}床头",
+                    contfigtype = 0,
+                    usechflag = 1,
+					flag = 0
+                });
+			}
+
+			if(softbed.has_bedframe == 1)
+			{
+                configureList.Add(new u_configure_type()
+                {
+                    contfigtypename = $"{prefix}床架",
+                    contfigtype = 0,
+                    usechflag = 1,
+                    flag = 0
+                });
+            }
+
+            if (softbed.has_nightstand == 1)
+            {
+                configureList.Add(new u_configure_type()
+                {
+                    contfigtypename = $"{prefix}床头柜",
+                    contfigtype = 0,
+                    usechflag = 1,
+                    flag = 0
+                });
+            }
 
+
+			var baseInfoHelper = GetHelper<BasicInfoHelper>(cmd, context);
+			foreach(var configure in configureList)
+            {
+                // 判断是否已存在
+                cmd.CommandText = @"SELECT COUNT(*) FROM u_configure_type WHERE LTRIM(RTRIM(contfigtypename)) = @contfigtypename";
+                cmd.Parameters.Clear();
+				cmd.Parameters.AddWithValue("@contfigtypename", configure.contfigtypename);
+				var cnt = Convert.ToInt32(cmd.ExecuteScalar());
+
+				if (cnt > 0) continue;
+                baseInfoHelper.SaveConfigureType(configure);
+            }
+        }
 		/// <summary>
 		/// 复制软床报价
 		/// </summary>

+ 1 - 0
JLHHJSvr/JLHHJSvr.csproj

@@ -453,6 +453,7 @@
     <Compile Include="Form2.Designer.cs">
       <DependentUpon>Form2.cs</DependentUpon>
     </Compile>
+    <Compile Include="Helper\BasicInfoHelper.cs" />
     <Compile Include="Helper\BedNetHelper.cs" />
     <Compile Include="Helper\CacheHelper.cs" />
     <Compile Include="Helper\ERPHelper.cs" />

+ 5 - 1
JLHWEB/src/enums/dwnameEnum.ts

@@ -189,5 +189,9 @@ export enum DwnameEnum {
   /*
    * @description 软床报价明细
    */
-  softbedQuoteMx = "u_softbed_mx"
+  softbedQuoteMx = "u_softbed_mx",
+  /**
+   * @description 软床模板报价-选择
+   */
+  softbedQuoteChoose = "u_softbed_choose"
 }

+ 3 - 0
JLHWEB/src/languages/modules/zh-cn/business.json

@@ -292,6 +292,9 @@
     },
     "codeMx": {
       "title": "配置选择"
+    },
+    "softbedTemplate": {
+      "title": "软床模板报价选择"
     }
   },
   "sptPriceChange": {

+ 7 - 0
JLHWEB/src/languages/modules/zh-cn/table.json

@@ -1568,5 +1568,12 @@
     "arg_datetype": "查询时间",
     "arg_firstdate": "开始时间",
     "arg_enddate": "结束时间"
+  },
+  "u_softbed": {
+    "softbed_code": "唯一码",
+    "softbed_relcode": "软床编码",
+    "softbed_name": "软床名称",
+    "template_code": "模板编号",
+    "template_name": "模板名称"
   }
 }

+ 1 - 0
JLHWEB/src/views/quote/softbedQuote/hooks/index.tsx

@@ -6,6 +6,7 @@ import { ElButton, ElMessage, ElMessageBox, ElRow, ElCol } 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";
 interface defaultState {
   /**
    * @description 单据当前状态

+ 170 - 0
JLHWEB/src/views/system/selector/softbedTemplate/index.vue

@@ -0,0 +1,170 @@
+<template>
+  <LjSelector
+    ref="LjSelectorRef"
+    :title="`${$t('business.selector.softbedTemplate.title')}`"
+    v-model:value="selectList"
+    v-bind="$attrs"
+    :item-key="TABLE_KEY"
+    :layout="layout"
+    @change-value="autoUpdateTableCheckbox"
+  >
+    <template #default>
+      <LjVxeTable
+        ref="LjTableRef"
+        table-cls=""
+        :columns="selColumns"
+        :request-api="getData"
+        :data-callback="dataCallback"
+        :init-param="initParams"
+        :dwname="DwnameEnum.softbedQuoteChoose"
+        pagination
+        :search-col="tableSearchCol"
+        :table-events="tableEvents"
+        :table-props="tableProps"
+        :tool-button="['refresh', 'setting', 'search']"
+        :auto-load-layout="false"
+        collapse-buttons
+        :page-change-call-back="autoUpdateTableCheckbox"
+      >
+      </LjVxeTable>
+    </template>
+  </LjSelector>
+</template>
+
+<script lang="tsx" setup name="SelectorSoftBedTemplateDialog">
+import { reactive, toRefs, ref, onMounted, nextTick, inject, watch, computed } from "vue";
+import LjVxeTable from "@/components/LjVxeTable/index.vue";
+import { useI18n } from "vue-i18n";
+import { DwnameEnum } from "@/enums/dwnameEnum";
+import { cloneDeep, pick, defaultsDeep } from "lodash-es";
+import { CommonDynamicSelect } from "@/api/modules/common";
+import { useAuthButtons } from "@/hooks/useAuthButtons";
+import { ColumnProps, SearchProps } from "@/components/LjVxeTable/interface";
+import LjSelector from "@/components/LjSelector/index.vue";
+
+const { t } = useI18n();
+
+const columns: ColumnProps<any>[] = [
+  {
+    field: "softbed_code",
+    search: {
+      el: "input",
+      key: "arg_search",
+      props: {
+        placeholder: "软床报价唯一码/名称/编码"
+      },
+      order: 2,
+      span: 2
+    }
+  }
+];
+
+const selColumns: any = computed(() => {
+  let selCol: any = { type: "radio", width: 50, fixed: "left" };
+  let _columns = cloneDeep(columns);
+  _columns.unshift(selCol);
+  return _columns;
+});
+
+/**
+ * @description 已选列表
+ */
+const selectList = ref<any>([]);
+const TABLE_KEY = "softbed_id";
+const layout = { first: { left: { hidden: true } } };
+
+const LjSelectorRef = ref();
+const LjTableRef = ref();
+const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
+
+const initParams = ref<any>({});
+const searchInput = ref("");
+const tableSearchCol = { xs: 8, sm: 8, md: 8, lg: 8, xl: 8 };
+const tableProps = {
+  height: "auto",
+  editConfig: { trigger: "click", mode: "cell" },
+  rowConfig: { isCurrent: true, isHover: true, useKey: true, keyField: TABLE_KEY }
+};
+
+/**
+ * @description 鼠标单击表格
+ */
+const handleClickTable = async ({ row, column, rowIndex }: any) => {
+  const $table = LjTableRef.value.element;
+  if ($table) {
+    selectList.value = [row];
+    $table.setRadioRow(row);
+  }
+};
+
+/**
+ * @description 鼠标双击表格
+ */
+const handleDBlClickTable = async ({ row, column, rowIndex }: any) => {
+  const $table = LjTableRef.value.element;
+  if ($table) {
+    selectList.value = [row];
+    $table.setRadioRow(row);
+
+    LjSelectorRef.value.funcSubmit();
+  }
+};
+
+// 返回绑定的事件
+const tableEvents = {
+  "cell-dblclick": handleDBlClickTable,
+  "cell-click": handleClickTable
+};
+
+const dataCallback = (data: any) => {
+  return {
+    list: data.datatable,
+    tableinfo: data.tableinfo,
+    total: data.totalcnt,
+    pageNum: data.pageindex,
+    pageSize: data.pagesize
+  };
+};
+
+const getData = (params: any) => {
+  let newParams: any = {};
+  params.pageNum && (newParams.pageindex = params.pageNum);
+  params.pageSize && (newParams.pagesize = params.pageSize);
+
+  delete params.pageNum;
+  delete params.pageSize;
+  newParams.queryParams = initParams.value;
+  newParams.queryParams = params;
+  newParams.dsname = "web_softbed_choose";
+  return CommonDynamicSelect(newParams, DwnameEnum.softbedQuoteChoose);
+};
+
+const autoUpdateTableCheckbox = () => {
+  const $table = LjTableRef.value.element;
+  if ($table && selectList.value.length) {
+    $table.clearCheckboxRow();
+    let _rows: any = [];
+    selectList.value.map((item: any) => {
+      if ($table.getRowById(item[TABLE_KEY])) {
+        _rows.push($table.getRowById(item[TABLE_KEY]));
+      }
+    });
+    _rows.length && $table.setCheckboxRow(_rows, true);
+  }
+};
+
+/**
+ * @description 打开组件
+ * @param params 入参
+ */
+const show = (params: any, label?: string) => {
+  selectList.value = [];
+  searchInput.value = "";
+  initParams.value = defaultsDeep(params, initParams.value);
+  LjSelectorRef.value.show(initParams.value);
+};
+
+defineExpose({
+  show
+});
+</script>

+ 130 - 0
JLHWEB/src/views/system/selector/softbedTemplate/select.vue

@@ -0,0 +1,130 @@
+<template>
+  <LjSelectorSelect
+    ref="selectSoftBedTemplateRef"
+    v-model:value="props.value"
+    value-key="softbed_id"
+    :loading="loading"
+    v-bind="$attrs"
+    :remote-method="remoteMethod"
+    popper-class="lj-select-mtrldef__popper"
+    @select="handleSelect"
+    @open-modal="openModal"
+  >
+    <template #label v-if="$slots?.label">
+      <slot name="label"></slot>
+    </template>
+    <template #header>
+      <div class="table-header lj-select__table">
+        <div class="table-tr">
+          <div class="table-td pr-4" style="width: 200px; max-width: 200px; min-width: 200px">
+            {{ $t("table.u_softbed.softbed_code") }}
+          </div>
+          <div class="table-td pr-4" style="width: 200px; max-width: 200px; min-width: 200px">
+            {{ $t("table.u_softbed.template_code") }}
+          </div>
+          <div class="table-td pr-4" style="width: 80px; max-width: 80px; min-width: 80px">
+            {{ $t("table.u_softbed.template_name") }}
+          </div>
+        </div>
+      </div>
+    </template>
+    <el-option
+      v-for="item in options"
+      :key="item.softbed_id"
+      :label="item.softbed_name"
+      :value="item"
+      class="lj-select__table pl-10 pr-10"
+      :class="{
+        'w-full': item.label
+      }"
+    >
+      <template v-if="item.label">
+        <div class="table-tr w-full text-center">{{ item.label }}</div>
+      </template>
+      <template v-else>
+        <div class="table-tr">
+          <div
+            style="width: 200px; max-width: 200px; min-width: 200px"
+            class="table-td pr-4 text-ellipsis-one"
+            :title="item.softbed_code"
+          >
+            {{ item.softbed_code }}
+          </div>
+          <div
+            style="width: 200px; max-width: 200px; min-width: 200px"
+            class="table-td pr-4 text-ellipsis-one"
+            :title="item.softbed_relcode"
+          >
+            {{ item.softbed_relcode }}
+          </div>
+          <div style="width: 80px; max-width: 80px; min-width: 80px" class="table-td pr-4 text-ellipsis-one">
+            {{ item.softbed_name }}
+          </div>
+        </div>
+      </template>
+    </el-option>
+  </LjSelectorSelect>
+</template>
+
+<script lang="ts" setup name="SelectorSoftBedTemplateSelect">
+import { ref, computed } from "vue";
+import { CommonDynamicSelect } from "@/api/modules/common";
+import { DwnameEnum } from "@/enums/dwnameEnum";
+import LjSelectorSelect from "@/components/LjSelector/select.vue";
+import { useUserStore } from "@/stores/modules/user";
+
+interface ProTableProps {
+  value: any;
+  [key: string]: any;
+}
+
+// 默认值
+const props = withDefaults(defineProps<ProTableProps>(), {});
+const { userInfo } = useUserStore();
+const emit = defineEmits(["select", "update:value", "openModal"]);
+const loading = ref(false);
+
+const remoteMethod = async (queryString: string) => {
+  loading.value = true;
+
+  let newParams: any = {};
+  newParams.pageindex = 1;
+  newParams.pagesize = 5;
+  newParams.queryParams = {
+    ...props,
+    arg_search: queryString
+  };
+  newParams.dsname = "web_softbed_choose";
+  let result = await CommonDynamicSelect(newParams, DwnameEnum.softbedQuoteChoose);
+
+  if (result.datatable.length) {
+    options.value = result.datatable;
+  } else {
+    options.value = [
+      {
+        label: "暂无数据",
+        disabled: true
+      }
+    ];
+  }
+
+  loading.value = false;
+};
+
+const handleSelect = (item: any) => {
+  emit("select", item);
+};
+
+const openModal = (e: any) => {
+  emit("openModal", e);
+};
+
+const selectSoftBedTemplateRef = ref();
+const toFocus = () => {
+  selectSoftBedTemplateRef.value.elment.focus();
+};
+
+defineExpose({
+  toFocus
+});
+</script>