Kaynağa Gözat

更新代码

MY 6 ay önce
ebeveyn
işleme
f932261e41

+ 6 - 6
JLHWEB/src/api/modules/saleprice.ts

@@ -38,13 +38,13 @@ export const DelteDept = (params: SalePrice.ReqDeleteDept) => {
  * @name 获取 工厂利润率
  */
 export const getProfitRateList = (params: any) => {
-  let queryParams = {};
-  let newParams = JSON.parse(JSON.stringify(params));
+  let newParams: any = {};
   newParams.dsname = "web_factory_profitratelist";
-  newParams.queryparams = queryParams;
-  newParams.kind = newParams.kind;
-  newParams.pageNum && (newParams.pageindex = newParams.pageNum);
-  newParams.pageSize && (newParams.pagesize = newParams.pageSize);
+  newParams.queryparams = params;
+  newParams.pageNum && (newParams.pageindex = params.pageNum);
+  newParams.pageSize && (newParams.pagesize = params.pageSize);
+  delete params.pageNum;
+  delete params.pageSize;
   return CommonDynamicSelect(newParams, "web_factory_profitratelist");
 };
 

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

@@ -21,5 +21,9 @@ export enum DwnameEnum {
   /**
    * @description 床垫报价明细
    */
-  mattressQuoteMx = "u_mattress_mx"
+  mattressQuoteMx = "u_mattress_mx",
+  /**
+   * @description 工厂利润率
+   */
+  profitratelist = "u_factory_profitrate"
 }

+ 102 - 0
JLHWEB/src/views/saleprice/profitrate/detail.vue

@@ -0,0 +1,102 @@
+<template>
+  <LjDetail
+    name="profitRateListDetail"
+    ref="LjDetailRef"
+    v-bind="detailProps"
+    v-model:order-status="orderStatus"
+    :data="mainData"
+    :init-param="mainData[0]"
+    :if-fold-layout="false"
+    :if-layout-editable="false"
+    :basic-group-col="{ xs: 2, sm: 2, md: 2, lg: 2, xl: 2 }"
+    :enum="props.enum"
+  >
+    <!-- :action="orderStatus ? orderEditAction : orderDefaultAction" -->
+  </LjDetail>
+</template>
+
+<script setup lang="tsx" name="profitRateListDetail">
+import { ref, watch, reactive, inject, onMounted } from "vue";
+import { DwnameEnum } from "@/enums/dwnameEnum";
+import LjDetail from "@/components/LjDetail/index.vue";
+import { DetailProp } from "@/components/LjDetail/interface";
+import { useI18n } from "vue-i18n";
+import { useHooks } from "./hooks/index";
+import { useAuthButtons } from "@/hooks/useAuthButtons";
+
+interface detailProp {
+  /**
+   * @argument any 页面数据
+   */
+  data?: any;
+  /**
+   * @argument string 请求数据的api ==> 非必传
+   */
+  requestApi?: (params: any) => Promise<any>;
+  /**
+   * @argument any 基础信息,表格展示数据
+   */
+  // columns?: any;
+  /**
+   * @description 是否可编辑
+   */
+  status: "edit" | "new" | string;
+  enum?: any;
+}
+
+const props = withDefaults(defineProps<detailProp>(), {});
+const { t } = useI18n();
+const { LjDetailRef, VxeTableRef, columns } = useHooks(t);
+const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
+
+const mainData = ref([{}]);
+
+/**
+ * @description 是否可编辑
+ */
+const orderStatus = ref("");
+
+const detailProps = reactive<DetailProp>({
+  dwname: DwnameEnum.profitratelist,
+  columns: columns,
+  // columns: VxeTableRef.value?.tableColumns,
+  // addPower: 5,
+  // editPower: 4359,
+  header: {
+    fieldNames: {
+      code: "deptname",
+      codeLabel: t("table.u_cust.cuscode") + ":",
+      name: "name"
+    },
+    icon: "iconuser-01",
+    tabsProp: {
+      scrollspy: false,
+      sticky: true
+    }
+  },
+  mould: []
+});
+
+watch(
+  () => props.data,
+  val => {
+    console.log("props.data, val :>> ", val);
+    mainData.value = [val];
+    // initParam.value.cusid = val.cusid;
+
+    // getDetailData(val).then(res => {
+    //   detailData.value = res;
+    // });
+  },
+  { immediate: true }
+);
+
+watch(
+  () => props.status,
+  val => {
+    console.log("props.status val :>> ", val);
+    orderStatus.value = val;
+  },
+  { immediate: true, deep: true }
+);
+</script>

+ 65 - 0
JLHWEB/src/views/saleprice/profitrate/hooks/index.tsx

@@ -0,0 +1,65 @@
+import { ref, reactive, computed, toRefs } from "vue";
+import { Table } from "@/hooks/interface";
+import { ColumnProps } from "@/components/LjVxeTable/interface";
+import { ALLOW_EDIT_STATE } from "@/config/index";
+import { SaveProfitRate } from "@/api/modules/saleprice";
+import { ElMessage, ElMessageBox } from "element-plus";
+interface defaultState {
+  /**
+   * @description 单据当前状态
+   */
+  orderStatus: string;
+  /**
+   * @description 列表Ref
+   */
+  VxeTableRef: any;
+  /**
+   * @description 详情页Ref
+   */
+  LjDetailRef: any;
+}
+
+const state = reactive<defaultState>({
+  orderStatus: "",
+  VxeTableRef: null,
+  LjDetailRef: null
+});
+
+// 表格配置项
+const columns: ColumnProps<any>[] = [];
+
+/**
+ * @description 表格多选数据操作
+ * @param {String} rowKey 当表格可以多选时,所指定的 id
+ * */
+export const useHooks = (t?: any) => {
+  // 保存
+  const fSave = (param: any) => {
+    return new Promise((resolve, reject) => {
+      ElMessageBox.confirm("是否确定要保存吗?", "询问", {
+        confirmButtonText: "是",
+        cancelButtonText: "否",
+        type: "warning"
+      })
+        .then(() => {
+          SaveProfitRate(param).then(() => {
+            ElMessage.success("保存成功!");
+            state.VxeTableRef?.refresh();
+            resolve({});
+          });
+        })
+        .catch(() => {
+          ElMessage({
+            type: "info",
+            message: "操作取消"
+          });
+        });
+    });
+  };
+
+  return {
+    ...toRefs(state),
+    columns,
+    fSave
+  };
+};

+ 209 - 1
JLHWEB/src/views/saleprice/profitrate/index.vue

@@ -1 +1,209 @@
-<template>123</template>
+<template>
+  <div class="table-box">
+    <LjVxeTable
+      ref="VxeTableRef"
+      row-key="deptid"
+      :columns="columns"
+      :request-api="getData"
+      :data-callback="dataCallback"
+      :init-param="initParams"
+      :dwname="dwname"
+      :table-props="tableProps"
+      :table-events="tableEvents"
+      :auto-load-layout="false"
+    >
+      <template #tableHeader>
+        <el-tabs v-model="initParams.kind" class="tableheader-tabs">
+          <el-tab-pane label="床网" :name="0"></el-tab-pane>
+          <el-tab-pane label="床垫" :name="1"></el-tab-pane>
+        </el-tabs>
+      </template>
+    </LjVxeTable>
+  </div>
+
+  <LjDialog
+    ref="LjDrawerRef"
+    class="is-selector"
+    v-bind="{
+      ...drawerDefineProp
+    }"
+    :style="{ padding: 0 }"
+  >
+    <template #header>
+      <div class="flx-1">
+        <span class="text-h5-b">部门: {{ deptname }}</span>
+      </div>
+    </template>
+    <div class="flx-1 h-full">
+      <LjHeaderMenu :data="mainData" :action="orderStatus ? orderEditAction : orderDefaultAction" />
+      <Detail class="flx-1" :data="mainData" :status="orderStatus" :enum="enumMap" />
+    </div>
+  </LjDialog>
+</template>
+
+<script setup lang="ts" name="saleprice_profitratelist">
+import { ref, onMounted, provide } from "vue";
+import { getProfitRateList } from "@/api/modules/saleprice";
+import { ColumnProps } from "@/components/LjVxeTable/interface";
+import LjDrawer from "@/components/LjDrawer/index.vue";
+import Detail from "./detail.vue";
+import { useHooks } from "./hooks/index";
+import LjDialog from "@/components/LjDialog/index.vue";
+import LjHeaderMenu from "@/components/LjHeaderMenu/index.vue";
+import { useI18n } from "vue-i18n";
+import { useAuthButtons } from "@/hooks/useAuthButtons";
+import { ALLOW_EDIT_STATE } from "@/config/index";
+import { cloneDeep } from "lodash-es";
+
+const dwname = "web_profitratelist";
+const mainData = ref({});
+const tableProps = {
+  height: "auto",
+  editConfig: { trigger: "click", mode: "cell" }
+  // rowClassName: rowClsNameFunc
+  // exportConfig: {
+  //   filename: t("menu.saletaskmx") + formatToDate(new Date(), "YYYY-MM-DD HH:mm:ss")
+  // }
+};
+
+const { t } = useI18n();
+const { VxeTableRef, LjDetailRef, columns } = useHooks(t);
+const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
+
+const initParams = ref({ kind: 0 });
+const orderStatus = ref("");
+const deptname = ref("");
+const enumMap = ref(new Map());
+
+const orderDefaultAction = [
+  buttonDefault({
+    label: t("common.cancelText"),
+    icon: "iconchevron-left"
+  }),
+  buttonNew({
+    label: t("common.saveText"),
+    icon: "iconsave-01",
+    clickFunc: item => {
+      // fSaveDept({ dept: LjDetailRef.value?.infoParam }).then(() => {
+      //   LjDrawerRef.value.hide();
+      // });
+    }
+  })
+];
+const orderEditAction = [
+  buttonNew({
+    label: t("common.saveText"),
+    icon: "iconsave-01",
+    clickFunc: item => {
+      // fSaveDept({ dept: LjDetailRef.value?.infoParam }).then(() => {
+      //   LjDrawerRef.value.hide();
+      // });
+
+      console.log("LjDetailRef.value?.infoParam :>>>>>", LjDetailRef.value);
+    }
+  })
+];
+
+/*
+ * @description 抽屉默认属性
+ */
+const drawerDefineProp = {
+  draggable: true,
+  overflow: true,
+  width: "40%"
+  // modalClass: "lj-file-dialog"
+};
+
+const getData = (params: any) => {
+  return getProfitRateList(params);
+};
+
+const dataCallback = (data: any) => {
+  let deptSet = new Map();
+  let bednetMap = new Map();
+
+  if (data.datatable?.length > 0) {
+    data.datatable?.forEach((item: any) => {
+      deptSet.has(item.deptid) || deptSet.set(item.deptid, {});
+      bednetMap.has(item.bednettypeid_mattresstypeid) || bednetMap.set(item.bednettypeid_mattresstypeid, item.typename);
+
+      let obj = deptSet.get(item.deptid);
+
+      Reflect.set(obj, "deptid", parseInt(item.deptid));
+      Reflect.set(obj, "deptname", item.deptname);
+      Reflect.set(obj, `bednettype_${item.bednettypeid_mattresstypeid}`, item.bednettypeid_mattresstypeid);
+      Reflect.set(obj, `profitrate_${item.bednettypeid_mattresstypeid}`, item.profitrate);
+    });
+  }
+
+  let datatable = Array.from(deptSet.values());
+
+  columns.length = 0;
+
+  columns.push({
+    type: "seq",
+    title: "#",
+    fixed: "left",
+    width: 80
+  });
+
+  columns.push({
+    field: "deptname",
+    title: "部门",
+    basicinfo: {
+      el: "input",
+      span: 2,
+      editable: ALLOW_EDIT_STATE,
+      props: {
+        readonly: true
+      }
+    }
+  });
+
+  for (let item of bednetMap) {
+    columns.push({
+      field: `profitrate_${item[0]}`,
+      title: item[1],
+      basicinfo: {
+        el: "input",
+        span: 2,
+        editable: ALLOW_EDIT_STATE,
+        props: {
+          placeholder: "请输入利润率"
+        },
+        rules: [{ required: true, message: "汇率不能为0", trigger: "change" }]
+      }
+    });
+  }
+
+  // if (data.tableinfo?.columns) {
+  //   data.tableinfo?.columns.map((item: any) => {
+  //     if (item?.enum) {
+  //       enumMap.value.set(item.field, item.enum);
+  //     }
+  //   });
+  // }
+  return {
+    list: datatable,
+    tableinfo: [],
+    total: data.totalcnt,
+    pageNum: data.pageindex,
+    pageSize: data.pagesize
+  };
+};
+
+const LjDrawerRef = ref();
+const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
+  // 弹窗
+  mainData.value = cloneDeep(row);
+  deptname.value = row.deptname;
+  orderStatus.value = "edit";
+  LjDrawerRef.value.show();
+};
+
+// 返回绑定的事件
+const tableEvents = {
+  "cell-dblclick": handleDBlClickTable
+  // "cell-click": handleClickTable
+};
+</script>