xiaodai2017 2 years ago
parent
commit
aa24e86a65

+ 0 - 2
src/components/BasicForm/src/_createDafaultData.ts

@@ -1,7 +1,5 @@
 import { FormItem } from "./types";
-import { isArray } from "/@/utils/validate";
 export function createDefaultData(formItems: FormItem[]) {
-  console.log(formItems);
   const data: Record<string, any> = {};
   //创建默认值策略
   for (const item of formItems) {

+ 225 - 0
src/views/operate/batchCreatUser/components/edit-dialog.vue

@@ -0,0 +1,225 @@
+<script setup lang="ts">
+import { FormRules, ElForm } from "element-plus";
+import { reactive, ref } from "vue";
+import { httpAdd } from "/@/api/operate/batchCreatUser";
+import { responseHandle } from "/@/utils/responseHandle";
+import { useNav } from "/@/layout/hooks/useNav";
+import { ElMessage } from "element-plus";
+import { Company, Card } from "/@/components/RemoteSelect";
+import dayjs from "dayjs";
+enum FROM_TYPE {
+  create = "create",
+  edit = "edit",
+  view = "view"
+}
+const { logout } = useNav();
+const showModel = ref(false);
+const TYPE = ref<FROM_TYPE>(FROM_TYPE.create);
+const formRef = ref<InstanceType<typeof ElForm>>(null);
+const loading = ref(false);
+const titleType = ref("");
+const year_options = ref([]);
+const id = ref("");
+const emit = defineEmits(["reload"]);
+const initform = {
+  company_id: "",
+  card_id: "",
+  username_prefix: "",
+  username_year: new Date().getFullYear() + "",
+  time: []
+};
+const ruleForm = ref({ ...initform });
+const rules = reactive<FormRules>({
+  company_id: [{ required: true, trigger: "change", message: "请选择企业" }],
+  card_id: [{ required: true, trigger: "change", message: "请选择企业" }],
+  username_prefix: [
+    { required: true, trigger: "change", message: "请选择原价" }
+  ],
+  username_year: [
+    { required: true, trigger: "change", message: "请选择活动价" }
+  ],
+  time: [
+    {
+      required: true,
+      type: "array",
+      trigger: "change",
+      message: "请选择活动日期"
+    }
+  ]
+});
+
+async function show(node: any, did: string, isCreate: string) {
+  id.value = did;
+  const nowYear = new Date().getFullYear();
+  const arr = [];
+  for (let i = nowYear + 1; i > 2020; i--) {
+    arr.push(i + "");
+  }
+  year_options.value = arr;
+  Object.keys(ruleForm.value).forEach(key => {
+    ruleForm.value[key] = initform[key];
+  });
+  TYPE.value = isCreate;
+  switch (TYPE.value) {
+    case "create":
+      titleType.value = "新建服务";
+      break;
+    case "edit":
+      titleType.value = "编辑服务";
+      break;
+    case "view":
+      titleType.value = "服务详情";
+      break;
+    default:
+      titleType.value = "新建服务";
+  }
+  showModel.value = true;
+}
+
+function handleCreate() {
+  const data = {
+    ...ruleForm.value
+  };
+  return {
+    data,
+    api: httpAdd
+  };
+}
+
+function handleSave() {
+  formRef.value.validate(async vaild => {
+    if (vaild) {
+      if (loading.value) return;
+      loading.value = true;
+      const { time } = ruleForm.value;
+      if (time.length !== 2) {
+        loading.value = false;
+        ElMessage.warning("活动时间不完整!");
+        return;
+      }
+
+      const handler = handleCreate;
+
+      const { api, data } = handler();
+      let model = JSON.parse(JSON.stringify(data));
+      model.starttime = dayjs(model.time[0]).format("YYYY-MM-DD");
+      model.endtime = dayjs(model.time[1]).format("YYYY-MM-DD");
+      delete model["time"];
+      const { message, code } = await api(model);
+      loading.value = false;
+      responseHandle({
+        code,
+        message,
+        logout,
+        handler: () => {
+          showModel.value = false;
+          emit("reload");
+        }
+      });
+    }
+  });
+}
+
+defineExpose({
+  show
+});
+</script>
+
+<template>
+  <el-dialog
+    v-model="showModel"
+    :close-on-press-escape="false"
+    center
+    append-to-body
+    destroy-on-close
+    :width="'650px'"
+    :title="titleType"
+    v-loading="loading"
+  >
+    <el-form
+      ref="formRef"
+      :model="ruleForm"
+      :rules="rules"
+      label-width="85px"
+      style="margin-top: -10px"
+      class="demo-ruleForm"
+      status-icon
+    >
+      <el-row>
+        <el-col :span="24">
+          <el-form-item label="企业名称" prop="company_id">
+            <Company
+              v-model="ruleForm.company_id"
+              :disabled="TYPE === 'view'"
+              placeholder="企业名称"
+            /> </el-form-item
+        ></el-col>
+        <el-col :span="24">
+          <el-form-item label="卡类型" prop="card_id">
+            <Card
+              v-model="ruleForm.card_id"
+              :disabled="TYPE === 'view'"
+              placeholder="卡类型"
+            /> </el-form-item
+        ></el-col>
+        <el-col :span="12">
+          <el-form-item label="前缀" prop="headname">
+            <span>CJ1745</span>
+          </el-form-item></el-col
+        >
+        <el-col :span="12">
+          <el-form-item label="字母段" prop="username_prefix">
+            <ElInput
+              placeholder="字母段"
+              :disabled="TYPE === 'view'"
+              maxlength="5"
+              v-model="ruleForm.username_prefix"
+            /> </el-form-item
+        ></el-col>
+        <el-col :span="12">
+          <el-form-item label="年份段" prop="username_year">
+            <el-select
+              v-model="ruleForm.username_year"
+              placeholder="年份段"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="(item, sii) in year_options"
+                :key="item + sii"
+                :label="item"
+                :value="item"
+              />
+            </el-select> </el-form-item
+        ></el-col>
+        <el-col :span="12">
+          <el-form-item label="数字段" prop="suffix">
+            <span>0000~9999</span></el-form-item
+          ></el-col
+        >
+
+        <el-col :span="24">
+          <el-form-item label="活动时间" prop="time">
+            <el-date-picker
+              v-model="ruleForm.time"
+              type="daterange"
+              :disabled="TYPE === 'view'"
+              range-separator="至"
+              start-placeholder="开始时间"
+              end-placeholder="结束时间"
+            /> </el-form-item
+        ></el-col>
+      </el-row>
+      <div class="flex justify-end">
+        <el-button
+          v-if="TYPE !== 'view'"
+          :loading="loading"
+          :disabled="loading"
+          type="primary"
+          @click="handleSave"
+          >保存</el-button
+        >
+        <el-button @click="showModel = false">取消</el-button>
+      </div>
+    </el-form>
+  </el-dialog>
+</template>

+ 0 - 66
src/views/operate/batchCreatUser/config/_details.ts

@@ -1,66 +0,0 @@
-/* eslint-disable prettier/prettier */
-import { FormConfig } from "/@/components/PageSearch";
-export const projectFormConfig: FormConfig = {
-  labelWidth: "85px",
-  formItems: [
-    {
-      label: "公司",
-      field: "company_id",
-      placeholder: "公司",
-      span: 24,
-      slot: "company_id"
-    },
-    {
-      label: "卡类型",
-      field: "card_id",
-      placeholder: "卡类型",
-      span: 24,
-      slot: "card_id"
-    },
-    {
-      label: "前缀",
-      field: "headname",
-      slot: "headname",
-      placeholder: "前缀",
-      span: 12
-    },
-    {
-      label: "字母段",
-      field: "username_prefix",
-      type: "input",
-      placeholder: "字母段",
-      span: 12
-    },
-    {
-      label: "年份段",
-      field: "username_year",
-      type: "number",
-      placeholder: "年份段",
-      span: 12
-    },
-
-    {
-      label: "数字段",
-      field: "suffix",
-      slot: "suffix",
-      placeholder: "数字段",
-      span: 12
-    },
-
-    {
-      label: "有效时间",
-      field: "time",
-      type: "date_picker",
-      otherOptions: {
-        type: "daterange",
-        startProp: "start",
-        endProp: "end",
-        startPlaceholder: "开始时间",
-        endPlaceholder: "结束时间",
-        format: "YYYY-MM-DD"
-      },
-      placeholder: "有效时间",
-      span: 24
-    }
-  ]
-};

+ 0 - 48
src/views/operate/batchCreatUser/config/_rules.ts

@@ -1,48 +0,0 @@
-import { FormRules } from "element-plus";
-import { isArray, validUpperCase } from "/@/utils/validate";
-export const projectFormRules: FormRules = {
-  company_id: {
-    trigger: "change",
-    required: true,
-    message: "请选择公司"
-  },
-  card_id: {
-    trigger: "change",
-    required: true,
-    message: "请选择卡类型"
-  },
-  headname: {
-    trigger: "change",
-    required: false,
-    message: "请选择账号固定前缀"
-  },
-  username_prefix: {
-    trigger: "change",
-    required: true,
-    validator(_, value) {
-      if (value === "") return new Error("请输入字母段");
-      if (!validUpperCase(value)) return new Error("字母段必须为大写字母!");
-      return true;
-    }
-  },
-  username_year: {
-    trigger: "change",
-    required: true,
-    validator(_, value) {
-      if (typeof value != "number") return new Error("请输入年份段");
-      const num = Number(value + "");
-      if (num < 0) return new Error("年份段不能低于0");
-      return true;
-    }
-  },
-  time: {
-    trigger: "change",
-    required: true,
-    validator(_, value) {
-      if (!isArray(value)) return new Error("请选择有效时间");
-      const length = value.length;
-      if (length === 0) return new Error("请选择有效时间");
-      return true;
-    }
-  }
-};

+ 0 - 14
src/views/operate/batchCreatUser/config/modal.config.ts

@@ -1,14 +0,0 @@
-import { ModalConfig } from "/@/components/PageModal/src/types";
-import { isLicense } from "/@/utils/validate";
-
-const modalConfig: ModalConfig = {
-  title: "批量创建账号",
-  colLayout: { span: 24 },
-  itemStyle: {},
-  contact: "batchCreatUser",
-  labelWidth: "100px",
-  width: "700px",
-  formItems: []
-};
-
-export default modalConfig;

+ 10 - 71
src/views/operate/batchCreatUser/index.vue

@@ -1,50 +1,22 @@
 <script setup lang="ts">
-import { ref, unref } from "vue";
 import { PageSearch, usePageSearch } from "/@/components/PageSearch";
 import searchConfig from "./config/search.config";
 import contentConfig from "./config/content.config";
-import PageAuth from "/@/components/PageAuth";
-import { PageModal, usePageModal } from "/@/components/PageModalShell";
-import modalConfig from "./config/modal.config";
-import { PageContent } from "/@/components/PageContent";
-import { Company, Card } from "/@/components/RemoteSelect";
-import { projectFormConfig } from "./config/_details";
-import { projectFormRules } from "./config/_rules";
 import { usePermission } from "/@/hooks/usePermission";
-import {
-  BasicForm,
-  transform,
-  createDefaultData
-} from "/@/components/BasicForm";
-import { ElForm } from "element-plus";
-const pageName = "batchCreatUser";
-import dayjs from "dayjs";
+import { PageContent } from "/@/components/PageContent";
+import { ref } from "vue";
+import EditModel from "./components/edit-dialog.vue";
 const { pageContentRef, handleResetClick, handleSearchClick } = usePageSearch(
   undefined,
   undefined,
   searchConfig
 );
-const { pageModalRef, handleCreateData, handleConfrim, defaultInfo } =
-  usePageModal({
-    pageContentRef
-  });
-
-const { formItems } = projectFormConfig;
+const pageName = "batchCreatUser";
+const modelRef = ref<InstanceType<typeof EditModel>>(null);
 const { hasPermissionWithCode, permissions } = usePermission(pageName);
-const basicFormRef = ref<InstanceType<typeof ElForm>>(null);
-const formData = ref<Record<string, any>>(createDefaultData(formItems));
-function handleCreate() {
-  basicFormRef.value.validate(isValid => {
-    if (!isValid) return;
-    const params = unref(formData);
-    const { time } = params;
-    params.starttime = time[0] ? dayjs(time[0]).format("YYYY-MM-DD") : "";
-    params.expiretime = time[1] ? dayjs(time[1]).format("YYYY-MM-DD") : "";
-    delete params["headname"];
-    delete params["suffix"];
-    delete params["title"];
-    handleConfrim("create", params);
-  });
+
+function handleAddChangeCheck(item: any, id: string, type: string) {
+  modelRef.value.show(item, id, type);
 }
 </script>
 
@@ -58,7 +30,7 @@ function handleCreate() {
       <template #action>
         <el-button
           type="primary"
-          @click="handleCreateData"
+          @click="handleAddChangeCheck({}, '', 'create')"
           v-if="hasPermissionWithCode('002')"
         >
           新增
@@ -70,39 +42,6 @@ function handleCreate() {
       :powers="permissions"
       :content-config="contentConfig"
     />
-    <PageModal
-      ref="pageModalRef"
-      :modal-config="modalConfig"
-      :default-info="defaultInfo"
-      @confirm-btn-click="handleConfrim"
-    >
-      <BasicForm
-        ref="basicFormRef"
-        v-bind="projectFormConfig"
-        :form-data="formData"
-        :rules="projectFormRules"
-        :disabled="false"
-        label-width="120px"
-      >
-        <template #company_id>
-          <Company v-model="formData.company_id" placeholder="公司" />
-        </template>
-        <template #card_id>
-          <Card v-model="formData.card_id" placeholder="卡类型" />
-        </template>
-        <template #headname>
-          <span>CJ1745</span>
-        </template>
-        <template #suffix>
-          <span>0000~9999</span>
-        </template>
-
-        <template #footer>
-          <div class="w-full flex justify-end">
-            <ElButton type="primary" @click="handleCreate">保存</ElButton>
-          </div>
-        </template>
-      </BasicForm>
-    </PageModal>
+    <EditModel ref="modelRef" @reload="pageContentRef.onSearch()" />
   </PageAuth>
 </template>

+ 185 - 0
src/views/operate/setComGood/components/edit-dialog.vue

@@ -0,0 +1,185 @@
+<script setup lang="ts">
+import { FormRules, ElForm } from "element-plus";
+import { reactive, ref } from "vue";
+import { httpUpdate, httpAdd, httpDetail } from "/@/api/operate/setComGood";
+import { responseHandle } from "/@/utils/responseHandle";
+import { useNav } from "/@/layout/hooks/useNav";
+
+import { ElMessage } from "element-plus";
+import { ComCard } from "/@/components/RemoteSelect";
+import LadderTable from "./ladder-table.vue";
+import OrderDialog from "/@/components/PageListModal";
+const modelRef = ref<InstanceType<typeof OrderDialog>>(null);
+import dayjs from "dayjs";
+enum FROM_TYPE {
+  create = "create",
+  edit = "edit",
+  view = "view"
+}
+const { logout } = useNav();
+const showModel = ref(false);
+const TYPE = ref<FROM_TYPE>(FROM_TYPE.create);
+const formRef = ref<InstanceType<typeof ElForm>>(null);
+
+const loading = ref(false);
+const titleType = ref("");
+const id = ref("");
+const emit = defineEmits(["reload"]);
+const initform = {
+  group_id: "",
+  good_id: []
+};
+const ruleForm = ref({ ...initform });
+const rules = reactive<FormRules>({
+  group_id: [
+    { required: true, trigger: "change", message: "请选择企业卡类型" }
+  ],
+  good_id: [
+    { required: true, type: "array", trigger: "change", message: "请选择商品" }
+  ]
+});
+const initData = async () => {
+  const { code, data, message } = await httpDetail({ id: id.value });
+  responseHandle({
+    code,
+    message,
+    logout,
+    handler: () => {
+      console.log(data);
+      Object.keys(ruleForm.value).forEach(key => {
+        ruleForm.value[key] = data[key] ? data[key] + "" : "";
+      });
+    }
+  });
+};
+async function show(node: any, did: string, isCreate: string) {
+  id.value = did;
+  Object.keys(ruleForm.value).forEach(key => {
+    ruleForm.value[key] = initform[key];
+  });
+  TYPE.value = isCreate;
+  switch (TYPE.value) {
+    case "create":
+      titleType.value = "新建公司商品";
+      break;
+    case "edit":
+      titleType.value = "编辑公司商品";
+      break;
+    case "view":
+      titleType.value = "公司商品详情";
+      break;
+    default:
+      titleType.value = "新建公司商品";
+  }
+  if (TYPE.value !== "create") {
+    await initData();
+  }
+
+  showModel.value = true;
+}
+
+function handleAddOrder(list) {
+  list.forEach(item => {
+    const { id } = item;
+    let findex = ruleForm.value.good_id.findIndex(e => e.id + "" == id + "");
+    if (findex == -1) {
+      ruleForm.value.good_id.push(item);
+    }
+  });
+}
+function handleSave() {
+  formRef.value.validate(async vaild => {
+    if (vaild) {
+      if (loading.value) return;
+      loading.value = true;
+      const { group_id, good_id } = ruleForm.value;
+      if (good_id.length > 0) {
+        loading.value = false;
+        ElMessage.warning("至少选择一个商品!");
+        return;
+      }
+      const good_id_arr = [];
+      good_id.forEach(si => {
+        good_id_arr.push(si.id);
+      });
+      const model = {
+        group_id,
+        good_id: good_id_arr
+      };
+
+      const { message, code } =
+        TYPE.value === FROM_TYPE.create
+          ? await httpAdd(model)
+          : await httpUpdate(model);
+      loading.value = false;
+      responseHandle({
+        code,
+        message,
+        logout,
+        handler: () => {
+          showModel.value = false;
+          emit("reload");
+        }
+      });
+    }
+  });
+}
+
+defineExpose({
+  show
+});
+</script>
+
+<template>
+  <el-dialog
+    v-model="showModel"
+    :close-on-press-escape="false"
+    center
+    append-to-body
+    destroy-on-close
+    :width="'1040px'"
+    :title="titleType"
+    v-loading="loading"
+  >
+    <el-form
+      ref="formRef"
+      :model="ruleForm"
+      :rules="rules"
+      label-width="100px"
+      style="margin-top: -10px"
+      class="demo-ruleForm"
+      status-icon
+    >
+      <el-row>
+        <el-col :span="24">
+          <el-form-item label="公司卡类型" prop="group_id">
+            <ComCard
+              v-model="ruleForm.group_id"
+              placeholder="公司卡类型"
+            /> </el-form-item
+        ></el-col>
+        <el-col :span="24">
+          <el-form-item label="商品列表" prop="good_id">
+            <LadderTable
+              :readonly="false"
+              :ladder="ruleForm.good_id"
+              @choose="() => modelRef.show('')"
+              @delete="index => ruleForm.good_id.splice(index, 1)"
+            /> </el-form-item
+        ></el-col>
+      </el-row>
+      <div class="flex justify-end">
+        <el-button
+          v-if="TYPE !== 'view'"
+          :loading="loading"
+          :disabled="loading"
+          type="primary"
+          @click="handleSave"
+          >保存</el-button
+        >
+        <el-button @click="showModel = false">取消</el-button>
+      </div>
+    </el-form>
+  </el-dialog>
+  <OrderDialog ref="modelRef" @save-btn-click="handleAddOrder" />
+</template>

+ 0 - 1
src/views/operate/setComGood/cpns/ladder-table.vue → src/views/operate/setComGood/components/ladder-table.vue

@@ -1,5 +1,4 @@
 <script setup lang="ts">
-// import { goodTypeOptions } from "../config/_options";
 import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
 import { GOOD_OPTIONS } from "/@/config/status";
 const emit = defineEmits(["choose", "delete", "update"]);

+ 0 - 21
src/views/operate/setComGood/config/_details.ts

@@ -1,21 +0,0 @@
-/* eslint-disable prettier/prettier */
-import { FormConfig } from "/@/components/PageSearch";
-export const projectFormConfig: FormConfig = {
-  formItems: [
-    {
-      label: "公司卡类型",
-      field: "group_id",
-      placeholder: "公司卡类型",
-      span: 24,
-      slot: "group_id"
-    },
-    {
-      label: "商品信息",
-      field: "good_id",
-      type: "array",
-      placeholder: "商品信息",
-      span: 24,
-      slot: "good_id"
-    }
-  ]
-};

+ 0 - 14
src/views/operate/setComGood/config/_rules.ts

@@ -1,14 +0,0 @@
-import { FormRules } from "element-plus";
-import { isArray, validUpperCase } from "/@/utils/validate";
-export const projectFormRules: FormRules = {
-  group_id: {
-    trigger: "change",
-    required: true,
-    message: "请选择公司卡类型"
-  },
-  good_id: {
-    trigger: "change",
-    required: true,
-    message: "请选择商品"
-  }
-};

+ 2 - 9
src/views/operate/setComGood/config/content.config.ts

@@ -1,11 +1,5 @@
 import { ContentConfig } from "/@/components/PageContent";
-import {
-  httpList,
-  httpAdd,
-  httpUpdate,
-  httpStatus,
-  httpDelete
-} from "/@/api/operate/setComGood";
+import { httpList, httpStatus, httpDelete } from "/@/api/operate/setComGood";
 import { GOOD_OPTIONS, STATUS_OPTIONS } from "/@/config/status";
 import { renderImage, renderStatus } from "/@/utils/column-helper";
 
@@ -90,10 +84,9 @@ const columns = [
 ];
 
 const contentConfig: ContentConfig = {
-  title: "商品管理",
+  title: "企业商品管理",
   columns,
   apis: {
-    httpAdd,
     httpList,
     httpStatus,
     httpDelete

+ 0 - 45
src/views/operate/setComGood/config/modal.config.ts

@@ -1,45 +0,0 @@
-import { ModalConfig } from "/@/components/PageModal/src/types";
-import { httpList as httpCompanylist } from "/@/api/parameter/company";
-import { httpList as httpCardlist } from "/@/api/parameter/card";
-const modalConfig: ModalConfig = {
-  title: "企业商品",
-  colLayout: { span: 24 },
-  itemStyle: {},
-  contact: "setComGood",
-  labelWidth: "85px",
-  formItems: [
-    {
-      field: "id",
-      type: "remote-select",
-      label: "公司卡类型",
-      placeholder: "公司卡类型",
-      otherOptions: {
-        api: httpCompanylist,
-        requesetProp: "title",
-        responseLabelProp: "title",
-        responseValPro: "id",
-        prop: "list"
-      },
-      span: 12,
-      rules: [{ required: true, trigger: "change", message: "请选择业务企业" }]
-    },
-    {
-      field: "name2",
-      type: "remote-select",
-      label: "卡类型",
-      placeholder: "卡类型",
-      otherOptions: {
-        api: httpCardlist,
-        responseLabelProp: "title",
-        responseValPro: "id",
-        requesetProp: "",
-        isRoot: false,
-        prop: "list"
-      },
-      span: 12,
-      rules: [{ required: true, trigger: "change", message: "请选择卡类型" }]
-    }
-  ]
-};
-
-export default modalConfig;

+ 3 - 8
src/views/operate/setComGood/config/search.config.ts

@@ -1,12 +1,7 @@
-import { ModalConfig } from "/@/components/PageModal/src/types";
-import { isLicense } from "/@/utils/validate";
+import { FormConfig } from "/@/components/PageSearch";
 import { STATUS_OPTIONS } from "/@/config/status";
 import { convertOptions } from "/@/utils/column-helper";
-const modalConfig: ModalConfig = {
-  title: "服务",
-  itemStyle: {},
-  contact: "setService",
-  labelWidth: "10px",
+const searchFormConfig: FormConfig = {
   formItems: [
     {
       field: "status",
@@ -34,4 +29,4 @@ const modalConfig: ModalConfig = {
   ]
 };
 
-export default modalConfig;
+export default searchFormConfig;

+ 0 - 82
src/views/operate/setComGood/cpns/ladder-modal.vue

@@ -1,82 +0,0 @@
-<script setup lang="ts">
-import { ref, unref, computed } from "vue";
-import { ElForm } from "element-plus";
-import { goodTypeOptions } from "../config/_options";
-import { ladderFormRules } from "../config/_rules";
-import { ImageUpload } from "/@/components/Upload";
-
-import { AmountInput, NumberInput } from "/@/components/Input";
-import GoodClass from "/@/components/GoodClass";
-
-const emit = defineEmits(["push", "update"]);
-
-const defaultData = {
-  budget_price: "0.00",
-  good_type: "1",
-  good_name: "",
-  cat_info: [],
-  num: "0"
-};
-
-const isUpdate = ref(false);
-const visible = ref(false);
-const formRef = ref<InstanceType<typeof ElForm> | null>(null);
-const updateIndex = ref("0");
-
-const formData = ref<Record<string, any>>({ ...defaultData });
-
-const title = computed(() => {
-  return isUpdate.value ? "修改商品要求" : "添加商品要求";
-});
-
-function handleConfirm() {
-  formRef.value.validate(isValid => {
-    if (!isValid) return;
-
-    emit(
-      isUpdate.value ? "update" : "push",
-      unref(formData),
-      unref(updateIndex)
-    );
-
-    visible.value = false;
-  });
-}
-
-defineExpose({
-  onDisplay: (data?: Record<string, any>, index = "0") => {
-    if (data) {
-      data.cat_info = [];
-      formData.value = data;
-      updateIndex.value = index;
-    }
-
-    visible.value = true;
-    isUpdate.value = !!data;
-  }
-});
-</script>
-
-<template>
-  <ElDialog
-    center
-    :title="title"
-    v-model="visible"
-    @close="() => (formData = { ...defaultData })"
-  >
-    <PageContent
-    ref="pageContentRef"
-    :content-config="contentConfig"
-    @create-btn-click="handleCreateData"
-  />
-
-    
-     
-        <div class="w-full flex justify-end">
-          <ElButton type="primary" @click="handleConfirm">保存</ElButton>
-          <ElButton @click="() => (visible = false)">取消</ElButton>
-        </div>
-    
-    
-  </ElDialog>
-</template>

+ 30 - 124
src/views/operate/setComGood/index.vue

@@ -2,141 +2,47 @@
 import { PageSearch, usePageSearch } from "/@/components/PageSearch";
 import searchConfig from "./config/search.config";
 import contentConfig from "./config/content.config";
-// import PageAuth from "/@/components/PageAuth";
-import { PageModal, usePageModal } from "/@/components/PageModalShell";
-import modalConfig from "./config/modal.config";
+import { usePermission } from "/@/hooks/usePermission";
 import { PageContent } from "/@/components/PageContent";
-import { ComCard } from "/@/components/RemoteSelect";
-import { projectFormConfig } from "./config/_details";
-import { projectFormRules } from "./config/_rules";
-import {
-  BasicForm,
-  transform,
-  createDefaultData
-} from "/@/components/BasicForm";
-import LadderTable from "./cpns/ladder-table.vue";
-import { ElImage } from "element-plus";
-import { httpDetail } from "/@/api/operate/setComGood";
-import { ElForm } from "element-plus";
-import { ref, unref } from "vue";
-import dayjs from "dayjs";
-import { useResponseHandle } from "/@/hooks/useAsync";
-import OrderDialog from "/@/components/PageListModal";
-const responseHandle = useResponseHandle();
+import { ref } from "vue";
+import EditModel from "./components/edit-dialog.vue";
+const pageName = "setComGood";
 const { pageContentRef, handleResetClick, handleSearchClick } = usePageSearch(
   undefined,
   undefined,
   searchConfig
 );
-const {
-  pageModalRef,
-  handleUpdateData,
-  handleCreateData,
-  handlePreviewData,
-  handleConfrim,
-  defaultInfo
-} = usePageModal({
-  pageContentRef
-});
 
-const { formItems } = projectFormConfig;
-const modelRef = ref<InstanceType<typeof OrderDialog>>(null);
-const basicFormRef = ref<InstanceType<typeof ElForm>>(null);
-const formData = ref<Record<string, any>>(createDefaultData(formItems));
-function handleCreate() {
-  basicFormRef.value.validate(isValid => {
-    console.log(isValid);
-    // if (!isValid) return;
-
-    const { group_id, good_id } = formData.value;
-    if (!group_id || good_id.length == 0) return;
-    console.log(formData.value);
-    const params = {
-      group_id,
-      good_id: []
-    };
-    good_id.forEach(si => {
-      console.log(si);
-      params.good_id.push(si.id);
-    });
-    handleConfrim("create", params);
-  });
-}
-async function handleDetailData(row, type) {
-  const { id } = row;
-  const { code, data, message } = await httpDetail({ id: id });
-  responseHandle({
-    code,
-    message,
-    handler: () => {
-      if (type === "preview") {
-        handlePreviewData(data);
-      }
-      if (type === "update") {
-        formData.value = transform(formItems, data, {});
-        handleUpdateData(data);
-      }
-    }
-  });
-}
-
-function handleAddOrder(list) {
-  list.forEach(item => {
-    const { id } = item;
-    let findex = formData.value.good_id.findIndex(e => e.id + "" == id + "");
-    if (findex == -1) {
-      formData.value.good_id.push(item);
-    }
-  });
+const modelRef = ref<InstanceType<typeof EditModel>>(null);
+const { hasPermissionWithCode, permissions } = usePermission(pageName);
+function handleAddChangeCheck(item: any, id: string, type: string) {
+  modelRef.value.show(item, id, type);
 }
 </script>
 
 <template>
-  <!-- <PageAuth :pageName="pageName"> -->
-  <PageSearch
-    :form-config="searchConfig"
-    @search-btn-click="handleSearchClick"
-    @reset-btn-click="handleResetClick"
-  />
-  <PageContent
-    ref="pageContentRef"
-    :content-config="contentConfig"
-    @create-btn-click="handleCreateData"
-    @preview-btn-click="row => handleDetailData(row, 'preview')"
-    @update-btn-click="row => handleDetailData(row, 'update')"
-  />
-  <PageModal
-    ref="pageModalRef"
-    :modal-config="modalConfig"
-    :default-info="defaultInfo"
-    @confirm-btn-click="handleConfrim"
-  >
-    <BasicForm
-      ref="basicFormRef"
-      v-bind="projectFormConfig"
-      :form-data="formData"
-      :rules="projectFormRules"
-      :disabled="false"
-      label-width="120px"
+  <PageAuth :pageName="pageName">
+    <PageSearch
+      :form-config="searchConfig"
+      @search-btn-click="handleSearchClick"
+      @reset-btn-click="handleResetClick"
     >
-      <template #group_id>
-        <ComCard v-model="formData.group_id" placeholder="公司卡类型" />
-      </template>
-      <template #good_id>
-        <LadderTable
-          :readonly="false"
-          :ladder="formData.good_id"
-          @choose="() => modelRef.show('')"
-          @delete="index => formData.good_id.splice(index, 1)"
-        />
-      </template>
-      <template #footer>
-        <div class="w-full flex justify-end">
-          <ElButton type="primary" @click="handleCreate">保存</ElButton>
-        </div>
+      <template #action>
+        <el-button
+          type="primary"
+          @click="handleAddChangeCheck({}, '', 'create')"
+          v-if="hasPermissionWithCode('002')"
+        >
+          新增
+        </el-button>
       </template>
-    </BasicForm>
-  </PageModal>
-  <OrderDialog ref="modelRef" @save-btn-click="handleAddOrder" />
-  <!-- </PageAuth> -->
+    </PageSearch>
+    <PageContent
+      ref="pageContentRef"
+      :powers="permissions"
+      :content-config="contentConfig"
+      @preview-btn-click="row => handleAddChangeCheck(row, row.id, 'view')"
+    />
+    <EditModel ref="modelRef" @reload="pageContentRef.onSearch()" />
+  </PageAuth>
 </template>

+ 0 - 3
src/views/operate/setTheme/cpns/addModel.vue

@@ -253,9 +253,6 @@ defineExpose({
                   />
                 </el-select>
               </el-form-item>
-              <!-- <el-form-item label="区域名称" prop="modular2_title">
-                <el-input v-model="ruleForm.modular2_title" />
-              </el-form-item> -->
             </el-col>
             <el-col :span="16">
               <el-form-item