Browse Source

处理负责人

ith5 5 tháng trước cách đây
mục cha
commit
899ad1c02d

+ 27 - 10
src/components/auth-select/index.vue

@@ -1,13 +1,4 @@
 <template>
 <template>
-  <!-- <a-select
-    @change="onUpdate"
-    :model-value="modelValue"
-    :options="authOptions"
-    placeholder="请选择负责人"
-    allow-search
-    :max-tag-count="1"
-    :multiple="multiple"
-    allow-clear /> -->
   <a-tree-select
   <a-tree-select
     :model-value="modelValue"
     :model-value="modelValue"
     :field-names="{ title: 'name', key: 'id' }"
     :field-names="{ title: 'name', key: 'id' }"
@@ -18,6 +9,7 @@
     :max-tag-count="2"
     :max-tag-count="2"
     allow-search
     allow-search
     allow-clear
     allow-clear
+    :filter-tree-node="filterTreeNode"
     placeholder="请选择负责人" />
     placeholder="请选择负责人" />
 </template>
 </template>
 <script setup>
 <script setup>
@@ -41,14 +33,39 @@ const emit = defineEmits(['update:modelValue'])
 const onUpdate = (val) => {
 const onUpdate = (val) => {
   emit('update:modelValue', val)
   emit('update:modelValue', val)
 }
 }
+// 搜索
+const filterTreeNode = (inputText, node) => {
+  return node.name.toLowerCase().indexOf(inputText.toLowerCase()) > -1
+}
 
 
 // 获取后台归属人列表
 // 获取后台归属人列表
 const getAuthList = async () => {
 const getAuthList = async () => {
   const res = await advertCommonApi.getAuthOptionsApi()
   const res = await advertCommonApi.getAuthOptionsApi()
   if (res.code == 200) {
   if (res.code == 200) {
-    authOptions.value = res.data
+    if (props.multiple) {
+      authOptions.value = res.data
+    } else {
+      const data = await handleData(res.data)
+      authOptions.value = data
+    }
   }
   }
 }
 }
+
+// 处理数据
+const handleData = (data) => {
+  return new Promise((resolve) => {
+    for (const item of data) {
+      if (item.id.includes('dept_id_')) {
+        item.disabled = true
+      }
+      if (item.children) {
+        handleData(item.children)
+      }
+    }
+    resolve(data)
+  })
+}
+
 onMounted(() => {
 onMounted(() => {
   getAuthList()
   getAuthList()
 })
 })

+ 5 - 1
src/components/sa-table/index.vue

@@ -695,7 +695,11 @@ const requestData = async () => {
   loading.value = true
   loading.value = true
   init()
   init()
   if (isFunction(currentApi.value)) {
   if (isFunction(currentApi.value)) {
-    const response = await currentApi.value(requestParams.value)
+    const params = cloneDeep(requestParams.value)
+    if (params.auth_id) {
+      params.auth_id = params.auth_id.filter((item) => String(item).indexOf('dept_id_') === -1)
+    }
+    const response = await currentApi.value(params)
     if (response.data && response.data.data) {
     if (response.data && response.data.data) {
       tableData.total = response.data.total
       tableData.total = response.data.total
       tableData.data = response.data.data
       tableData.data = response.data.data

+ 76 - 104
src/views/v1/advert/agenList/addSite.vue

@@ -7,50 +7,21 @@
     :mask-closable="false"
     :mask-closable="false"
     :ok-loading="loading"
     :ok-loading="loading"
     @cancel="close"
     @cancel="close"
-    @before-ok="submit"
-  >
+    @before-ok="submit">
     <!-- 表单信息 start -->
     <!-- 表单信息 start -->
-    <a-form
-      ref="formRef"
-      :model="formData"
-      :rules="rules"
-      :auto-label-width="true"
-    >
+    <a-form ref="formRef" :model="formData" :rules="rules" :auto-label-width="true">
       <a-form-item label="媒体ID" field="media_id">
       <a-form-item label="媒体ID" field="media_id">
-        <a-select
-          v-model="formData.media_id"
-          placeholder="请选择媒体ID"
-          allow-clear
-        >
-          <a-option
-            v-for="item in mediaOptions"
-            :key="item.id"
-            :value="item.id"
-            :label="`${item.id}:${item.name}`"
-          />
+        <a-select v-model="formData.media_id" placeholder="请选择媒体ID" allow-clear>
+          <a-option v-for="item in mediaOptions" :key="item.id" :value="item.id" :label="`${item.id}:${item.name}`" />
         </a-select>
         </a-select>
       </a-form-item>
       </a-form-item>
       <a-form-item label="渠道ID" field="agent_id">
       <a-form-item label="渠道ID" field="agent_id">
-        <a-select
-          v-model="formData.agent_id"
-          placeholder="请选择渠道ID"
-          allow-clear
-        >
-          <a-option
-            v-for="item in agentOptions"
-            :key="item.id"
-            :value="item.id"
-            :label="`${item.id}:${item.name}`"
-          />
+        <a-select v-model="formData.agent_id" placeholder="请选择渠道ID" allow-clear>
+          <a-option v-for="item in agentOptions" :key="item.id" :value="item.id" :label="`${item.id}:${item.name}`" />
         </a-select>
         </a-select>
       </a-form-item>
       </a-form-item>
       <a-form-item label="负责人ID" field="auth_id">
       <a-form-item label="负责人ID" field="auth_id">
-        <a-select
-          v-model="formData.auth_id"
-          :options="authOptions"
-          placeholder="请选择负责人ID"
-          allow-clear
-        />
+        <auth-select v-model="formData.auth_id" />
       </a-form-item>
       </a-form-item>
       <a-form-item label="广告位名称" field="name">
       <a-form-item label="广告位名称" field="name">
         <a-input v-model="formData.name" placeholder="请输入广告位名称" />
         <a-input v-model="formData.name" placeholder="请输入广告位名称" />
@@ -61,27 +32,28 @@
 </template>
 </template>
 
 
 <script setup>
 <script setup>
-import { ref, reactive, computed } from "vue";
-import tool from "@/utils/tool";
-import { Message, Modal } from "@arco-design/web-vue";
-import api from "../../api/advert/agentSite";
-import advertCommonApi from "../../api/advert/common";
-import { useUserStore } from "@/store";
+import { ref, reactive, computed } from 'vue'
+import tool from '@/utils/tool'
+import { Message, Modal } from '@arco-design/web-vue'
+import api from '../../api/advert/agentSite'
+import advertCommonApi from '../../api/advert/common'
+import { useUserStore } from '@/store'
+import authSelect from '@/components/auth-select/index.vue'
 
 
-const emit = defineEmits(["success"]);
+const emit = defineEmits(['success'])
 // 引用定义
 // 引用定义
-const visible = ref(false);
-const loading = ref(false);
-const formRef = ref();
-const mode = ref("");
-const userStore = useUserStore();
-const mediaOptions = ref([]);
-const authOptions = ref([]);
-const agentOptions = ref([]);
+const visible = ref(false)
+const loading = ref(false)
+const formRef = ref()
+const mode = ref('')
+const userStore = useUserStore()
+const mediaOptions = ref([])
+const authOptions = ref([])
+const agentOptions = ref([])
 
 
 let title = computed(() => {
 let title = computed(() => {
-  return "广告位" + (mode.value == "add" ? "-新增" : "-编辑");
-});
+  return '广告位' + (mode.value == 'add' ? '-新增' : '-编辑')
+})
 
 
 // 表单初始值
 // 表单初始值
 const initialFormData = {
 const initialFormData = {
@@ -89,105 +61,105 @@ const initialFormData = {
   media_id: null,
   media_id: null,
   agent_id: null,
   agent_id: null,
   auth_id: null,
   auth_id: null,
-  name: "",
-};
+  name: '',
+}
 
 
 // 表单信息
 // 表单信息
-const formData = reactive({ ...initialFormData });
+const formData = reactive({ ...initialFormData })
 
 
 // 验证规则
 // 验证规则
 const rules = {
 const rules = {
-  media_id: [{ required: true, message: "媒体ID必需填写" }],
-  agent_id: [{ required: true, message: "渠道ID必需填写" }],
-  auth_id: [{ required: true, message: "负责人ID必需填写" }],
-  name: [{ required: true, message: "广告位名称必需填写" }],
-};
+  media_id: [{ required: true, message: '媒体ID必需填写' }],
+  agent_id: [{ required: true, message: '渠道ID必需填写' }],
+  auth_id: [{ required: true, message: '负责人ID必需填写' }],
+  name: [{ required: true, message: '广告位名称必需填写' }],
+}
 
 
 // 获取媒体列表Options
 // 获取媒体列表Options
 const getMediaOptions = async () => {
 const getMediaOptions = async () => {
-  const res = await advertCommonApi.getMediaOptionsApi();
+  const res = await advertCommonApi.getMediaOptionsApi()
   if (res.code == 200) {
   if (res.code == 200) {
-    mediaOptions.value = res.data;
+    mediaOptions.value = res.data
   }
   }
-};
+}
 
 
 // 获取渠道列表Options
 // 获取渠道列表Options
 const getAgentOptions = async () => {
 const getAgentOptions = async () => {
-  const res = await advertCommonApi.getAgentOptionsApi();
+  const res = await advertCommonApi.getAgentOptionsApi()
   if (res.code == 200) {
   if (res.code == 200) {
-    agentOptions.value = res.data;
+    agentOptions.value = res.data
   }
   }
-};
+}
 
 
 // 获取后台归属人列表
 // 获取后台归属人列表
 const getAuthList = async () => {
 const getAuthList = async () => {
-  const res = await advertCommonApi.getAuthOptionsApi();
+  const res = await advertCommonApi.getAuthOptionsApi()
   if (res.code == 200) {
   if (res.code == 200) {
-    authOptions.value = res.data;
+    authOptions.value = res.data
   }
   }
-};
+}
 
 
 // 打开弹框
 // 打开弹框
-const open = async (type = "add") => {
-  mode.value = type;
+const open = async (type = 'add') => {
+  mode.value = type
   // 重置表单数据
   // 重置表单数据
-  Object.assign(formData, initialFormData);
-  formRef.value.clearValidate();
-  visible.value = true;
-  if (mode.value === "add") {
-    formData.auth_id = userStore.user.id;
+  Object.assign(formData, initialFormData)
+  formRef.value.clearValidate()
+  visible.value = true
+  if (mode.value === 'add') {
+    formData.auth_id = userStore.user.id
   }
   }
-  await initPage();
-};
+  await initPage()
+}
 
 
 // 初始化页面数据
 // 初始化页面数据
 const initPage = async () => {
 const initPage = async () => {
-  await getMediaOptions();
-  await getAgentOptions();
-  await getAuthList();
-};
+  await getMediaOptions()
+  await getAgentOptions()
+  await getAuthList()
+}
 
 
 // 设置数据
 // 设置数据
 const setFormData = async (data) => {
 const setFormData = async (data) => {
   for (const key in formData) {
   for (const key in formData) {
     if (data[key] != null && data[key] != undefined) {
     if (data[key] != null && data[key] != undefined) {
-      formData[key] = data[key];
+      formData[key] = data[key]
     }
     }
   }
   }
-  formData["name"] = "";
-  formData["agent_id"] = data.id;
-};
+  formData['name'] = ''
+  formData['agent_id'] = data.id
+}
 
 
 // 数据保存
 // 数据保存
 const submit = async (done) => {
 const submit = async (done) => {
-  const validate = await formRef.value?.validate();
+  const validate = await formRef.value?.validate()
   if (!validate) {
   if (!validate) {
-    loading.value = true;
-    let data = { ...formData };
-    let result = {};
-    if (mode.value === "add") {
+    loading.value = true
+    let data = { ...formData }
+    let result = {}
+    if (mode.value === 'add') {
       // 添加数据
       // 添加数据
-      data.id = undefined;
-      result = await api.save(data);
+      data.id = undefined
+      result = await api.save(data)
     } else {
     } else {
       // 修改数据
       // 修改数据
-      result = await api.update(data.id, data);
+      result = await api.update(data.id, data)
     }
     }
     if (result.code === 200) {
     if (result.code === 200) {
-      Message.success("操作成功");
-      emit("success");
-      done(true);
+      Message.success('操作成功')
+      emit('success')
+      done(true)
     }
     }
     // 防止连续点击提交
     // 防止连续点击提交
     setTimeout(() => {
     setTimeout(() => {
-      loading.value = false;
-    }, 500);
+      loading.value = false
+    }, 500)
   }
   }
-  done(false);
-};
+  done(false)
+}
 
 
 // 关闭弹窗
 // 关闭弹窗
-const close = () => (visible.value = false);
+const close = () => (visible.value = false)
 
 
-defineExpose({ open, setFormData });
+defineExpose({ open, setFormData })
 </script>
 </script>

+ 69 - 88
src/views/v1/advert/agenList/edit.vue

@@ -7,39 +7,19 @@
     :mask-closable="false"
     :mask-closable="false"
     :ok-loading="loading"
     :ok-loading="loading"
     @cancel="close"
     @cancel="close"
-    @before-ok="submit"
-  >
+    @before-ok="submit">
     <!-- 表单信息 start -->
     <!-- 表单信息 start -->
-    <a-form
-      ref="formRef"
-      :model="formData"
-      :rules="rules"
-      :auto-label-width="true"
-    >
+    <a-form ref="formRef" :model="formData" :rules="rules" :auto-label-width="true">
       <a-form-item label="渠道类型" field="media_id">
       <a-form-item label="渠道类型" field="media_id">
-        <a-select
-          v-model="formData.media_id"
-          placeholder="请选择渠道类型"
-          allow-clear
-        >
-          <a-option
-            v-for="item in mediaOptions"
-            :key="item.id"
-            :value="item.id"
-            :label="`${item.id}:${item.name}`"
-          />
+        <a-select v-model="formData.media_id" placeholder="请选择渠道类型" allow-clear>
+          <a-option v-for="item in mediaOptions" :key="item.id" :value="item.id" :label="`${item.id}:${item.name}`" />
         </a-select>
         </a-select>
       </a-form-item>
       </a-form-item>
       <a-form-item label="渠道名称" field="name">
       <a-form-item label="渠道名称" field="name">
         <a-input v-model="formData.name" placeholder="请输入渠道名称" />
         <a-input v-model="formData.name" placeholder="请输入渠道名称" />
       </a-form-item>
       </a-form-item>
       <a-form-item label="后台归属人" field="auth_id">
       <a-form-item label="后台归属人" field="auth_id">
-        <a-select
-          v-model="formData.auth_id"
-          :options="authOptions"
-          placeholder="请选择后台归属人"
-          allow-clear
-        />
+        <auth-select v-model="formData.auth_id" />
       </a-form-item>
       </a-form-item>
     </a-form>
     </a-form>
     <!-- 表单信息 end -->
     <!-- 表单信息 end -->
@@ -47,124 +27,125 @@
 </template>
 </template>
 
 
 <script setup>
 <script setup>
-import { ref, reactive, computed } from "vue";
-import tool from "@/utils/tool";
-import { Message, Modal } from "@arco-design/web-vue";
-import api from "../../api/advert/agenList";
-import advertCommonApi from "../../api/advert/common";
-import { useUserStore } from "@/store";
-const emit = defineEmits(["success"]);
+import { ref, reactive, computed } from 'vue'
+import tool from '@/utils/tool'
+import { Message, Modal } from '@arco-design/web-vue'
+import api from '../../api/advert/agenList'
+import advertCommonApi from '../../api/advert/common'
+import authSelect from '@/components/auth-select/index.vue'
+import { useUserStore } from '@/store'
+const emit = defineEmits(['success'])
 // 引用定义
 // 引用定义
-const visible = ref(false);
-const loading = ref(false);
-const formRef = ref();
-const mode = ref("");
-const mediaOptions = ref([]);
-const authOptions = ref([]);
-const userStore = useUserStore();
+const visible = ref(false)
+const loading = ref(false)
+const formRef = ref()
+const mode = ref('')
+const mediaOptions = ref([])
+const authOptions = ref([])
+const userStore = useUserStore()
 
 
 let title = computed(() => {
 let title = computed(() => {
-  return "渠道管理" + (mode.value == "add" ? "-新增" : "-编辑");
-});
+  return '渠道管理' + (mode.value == 'add' ? '-新增' : '-编辑')
+})
 
 
 // 表单初始值
 // 表单初始值
 const initialFormData = {
 const initialFormData = {
   id: null,
   id: null,
   auth_id: null,
   auth_id: null,
-  name: "",
+  name: '',
   media_id: null,
   media_id: null,
-};
+}
 
 
 // 表单信息
 // 表单信息
-const formData = reactive({ ...initialFormData });
+const formData = reactive({ ...initialFormData })
 
 
 // 验证规则
 // 验证规则
 const rules = {
 const rules = {
-  auth_id: [{ required: true, message: "后台归属人必需填写" }],
-  name: [{ required: true, message: "渠道名称必需填写" }],
-  media_id: [{ required: true, message: "媒体ID必需填写" }],
-};
+  auth_id: [{ required: true, message: '后台归属人必需填写' }],
+  name: [{ required: true, message: '渠道名称必需填写' }],
+  media_id: [{ required: true, message: '媒体ID必需填写' }],
+}
 
 
 // 打开弹框
 // 打开弹框
-const open = async (type = "add") => {
-  mode.value = type;
+const open = async (type = 'add') => {
+  mode.value = type
   // 重置表单数据
   // 重置表单数据
-  Object.assign(formData, initialFormData);
-  formRef.value.clearValidate();
-  visible.value = true;
-  if (mode.value === "add") {
-    formData.auth_id = userStore.user.id;
+  Object.assign(formData, initialFormData)
+  formRef.value.clearValidate()
+  visible.value = true
+  if (mode.value === 'add') {
+    formData.auth_id = userStore.user.id
   }
   }
-  await initPage();
-};
+  await initPage()
+}
 
 
 // 初始化页面数据
 // 初始化页面数据
 const initPage = async () => {
 const initPage = async () => {
-  await getMediaOptions();
-  await getAuthList();
-};
+  await getMediaOptions()
+  await getAuthList()
+}
 
 
 // 获取媒体列表Options
 // 获取媒体列表Options
 const getMediaOptions = async () => {
 const getMediaOptions = async () => {
-  const res = await advertCommonApi.getMediaOptionsApi();
+  const res = await advertCommonApi.getMediaOptionsApi()
   if (res.code == 200) {
   if (res.code == 200) {
-    mediaOptions.value = res.data;
+    mediaOptions.value = res.data
   }
   }
-};
+}
 
 
 // 获取后台归属人列表
 // 获取后台归属人列表
 const getAuthList = async () => {
 const getAuthList = async () => {
-  const res = await advertCommonApi.getAuthOptionsApi();
+  const res = await advertCommonApi.getAuthOptionsApi()
   if (res.code == 200) {
   if (res.code == 200) {
-    authOptions.value = res.data;
+    authOptions.value = res.data
   }
   }
-};
+}
 
 
 // 从缓存中获取用户的id
 // 从缓存中获取用户的id
 const getUserId = async () => {
 const getUserId = async () => {
-  const userInfo = JSON.parse(localStorage.getItem("userInfo"));
-  userId.value = userInfo.id;
-};
+  const userInfo = JSON.parse(localStorage.getItem('userInfo'))
+  userId.value = userInfo.id
+}
 
 
 // 设置数据
 // 设置数据
 const setFormData = async (data) => {
 const setFormData = async (data) => {
   for (const key in formData) {
   for (const key in formData) {
     if (data[key] != null && data[key] != undefined) {
     if (data[key] != null && data[key] != undefined) {
-      formData[key] = data[key];
+      formData[key] = data[key]
     }
     }
   }
   }
-};
+}
 
 
 // 数据保存
 // 数据保存
 const submit = async (done) => {
 const submit = async (done) => {
-  const validate = await formRef.value?.validate();
+  const validate = await formRef.value?.validate()
   if (!validate) {
   if (!validate) {
-    loading.value = true;
-    let data = { ...formData };
-    let result = {};
-    if (mode.value === "add") {
+    loading.value = true
+    let data = { ...formData }
+    let result = {}
+    if (mode.value === 'add') {
       // 添加数据
       // 添加数据
-      data.id = undefined;
-      result = await api.save(data);
+      data.id = undefined
+      result = await api.save(data)
     } else {
     } else {
       // 修改数据
       // 修改数据
-      result = await api.update(data.id, data);
+      result = await api.update(data.id, data)
     }
     }
     if (result.code === 200) {
     if (result.code === 200) {
-      Message.success("操作成功");
-      emit("success");
-      done(true);
+      Message.success('操作成功')
+      emit('success')
+      done(true)
     }
     }
     // 防止连续点击提交
     // 防止连续点击提交
     setTimeout(() => {
     setTimeout(() => {
-      loading.value = false;
-    }, 500);
+      loading.value = false
+    }, 500)
   }
   }
-  done(false);
-};
+  done(false)
+}
 
 
 // 关闭弹窗
 // 关闭弹窗
-const close = () => (visible.value = false);
+const close = () => (visible.value = false)
 
 
-defineExpose({ open, setFormData });
+defineExpose({ open, setFormData })
 </script>
 </script>

+ 74 - 105
src/views/v1/advert/agentSite/edit.vue

@@ -7,53 +7,21 @@
     :mask-closable="false"
     :mask-closable="false"
     :ok-loading="loading"
     :ok-loading="loading"
     @cancel="close"
     @cancel="close"
-    @before-ok="submit"
-  >
+    @before-ok="submit">
     <!-- 表单信息 start -->
     <!-- 表单信息 start -->
-    <a-form
-      ref="formRef"
-      :model="formData"
-      :rules="rules"
-      :auto-label-width="true"
-    >
+    <a-form ref="formRef" :model="formData" :rules="rules" :auto-label-width="true">
       <a-form-item label="媒体ID" field="media_id">
       <a-form-item label="媒体ID" field="media_id">
-        <a-select
-          v-model="formData.media_id"
-          placeholder="请选择媒体ID"
-          allow-clear
-          :disabled="mode === 'edit'"
-        >
-          <a-option
-            v-for="item in mediaOptions"
-            :key="item.id"
-            :value="item.id"
-            :label="`${item.id}:${item.name}`"
-          />
+        <a-select v-model="formData.media_id" placeholder="请选择媒体ID" allow-clear :disabled="mode === 'edit'">
+          <a-option v-for="item in mediaOptions" :key="item.id" :value="item.id" :label="`${item.id}:${item.name}`" />
         </a-select>
         </a-select>
       </a-form-item>
       </a-form-item>
       <a-form-item label="渠道ID" field="agent_id">
       <a-form-item label="渠道ID" field="agent_id">
-        <a-select
-          v-model="formData.agent_id"
-          placeholder="请选择渠道ID"
-          allow-clear
-          :disabled="mode === 'edit'"
-        >
-          <a-option
-            v-for="item in agentOptions"
-            :key="item.id"
-            :value="item.id"
-            :label="`${item.id}:${item.name}`"
-          />
+        <a-select v-model="formData.agent_id" placeholder="请选择渠道ID" allow-clear :disabled="mode === 'edit'">
+          <a-option v-for="item in agentOptions" :key="item.id" :value="item.id" :label="`${item.id}:${item.name}`" />
         </a-select>
         </a-select>
       </a-form-item>
       </a-form-item>
       <a-form-item label="负责人ID" field="auth_id">
       <a-form-item label="负责人ID" field="auth_id">
-        <a-select
-          v-model="formData.auth_id"
-          :options="authOptions"
-          placeholder="请选择负责人ID"
-          allow-clear
-          :disabled="mode === 'edit'"
-        />
+        <auth-select v-model="formData.auth_id" />
       </a-form-item>
       </a-form-item>
       <a-form-item label="广告位名称" field="name">
       <a-form-item label="广告位名称" field="name">
         <a-input v-model="formData.name" placeholder="请输入广告位名称" />
         <a-input v-model="formData.name" placeholder="请输入广告位名称" />
@@ -64,27 +32,28 @@
 </template>
 </template>
 
 
 <script setup>
 <script setup>
-import { ref, reactive, computed } from "vue";
-import tool from "@/utils/tool";
-import { Message, Modal } from "@arco-design/web-vue";
-import api from "../../api/advert/agentSite";
-import advertCommonApi from "../../api/advert/common";
-import { useUserStore } from "@/store";
+import { ref, reactive, computed } from 'vue'
+import tool from '@/utils/tool'
+import { Message, Modal } from '@arco-design/web-vue'
+import api from '../../api/advert/agentSite'
+import advertCommonApi from '../../api/advert/common'
+import { useUserStore } from '@/store'
+import authSelect from '@/components/auth-select/index.vue'
 
 
-const emit = defineEmits(["success"]);
+const emit = defineEmits(['success'])
 // 引用定义
 // 引用定义
-const visible = ref(false);
-const loading = ref(false);
-const formRef = ref();
-const mode = ref("");
-const userStore = useUserStore();
-const mediaOptions = ref([]);
-const authOptions = ref([]);
-const agentOptions = ref([]);
+const visible = ref(false)
+const loading = ref(false)
+const formRef = ref()
+const mode = ref('')
+const userStore = useUserStore()
+const mediaOptions = ref([])
+const authOptions = ref([])
+const agentOptions = ref([])
 
 
 let title = computed(() => {
 let title = computed(() => {
-  return "广告位" + (mode.value == "add" ? "-新增" : "-编辑");
-});
+  return '广告位' + (mode.value == 'add' ? '-新增' : '-编辑')
+})
 
 
 // 表单初始值
 // 表单初始值
 const initialFormData = {
 const initialFormData = {
@@ -92,103 +61,103 @@ const initialFormData = {
   media_id: null,
   media_id: null,
   agent_id: null,
   agent_id: null,
   auth_id: null,
   auth_id: null,
-  name: "",
-};
+  name: '',
+}
 
 
 // 表单信息
 // 表单信息
-const formData = reactive({ ...initialFormData });
+const formData = reactive({ ...initialFormData })
 
 
 // 验证规则
 // 验证规则
 const rules = {
 const rules = {
-  media_id: [{ required: true, message: "媒体ID必需填写" }],
-  agent_id: [{ required: true, message: "渠道ID必需填写" }],
-  auth_id: [{ required: true, message: "负责人ID必需填写" }],
-  name: [{ required: true, message: "广告位名称必需填写" }],
-};
+  media_id: [{ required: true, message: '媒体ID必需填写' }],
+  agent_id: [{ required: true, message: '渠道ID必需填写' }],
+  auth_id: [{ required: true, message: '负责人ID必需填写' }],
+  name: [{ required: true, message: '广告位名称必需填写' }],
+}
 
 
 // 获取媒体列表Options
 // 获取媒体列表Options
 const getMediaOptions = async () => {
 const getMediaOptions = async () => {
-  const res = await advertCommonApi.getMediaOptionsApi();
+  const res = await advertCommonApi.getMediaOptionsApi()
   if (res.code == 200) {
   if (res.code == 200) {
-    mediaOptions.value = res.data;
+    mediaOptions.value = res.data
   }
   }
-};
+}
 
 
 // 获取渠道列表Options
 // 获取渠道列表Options
 const getAgentOptions = async () => {
 const getAgentOptions = async () => {
-  const res = await advertCommonApi.getAgentOptionsApi();
+  const res = await advertCommonApi.getAgentOptionsApi()
   if (res.code == 200) {
   if (res.code == 200) {
-    agentOptions.value = res.data;
+    agentOptions.value = res.data
   }
   }
-};
+}
 
 
 // 获取后台归属人列表
 // 获取后台归属人列表
 const getAuthList = async () => {
 const getAuthList = async () => {
-  const res = await advertCommonApi.getAuthOptionsApi();
+  const res = await advertCommonApi.getAuthOptionsApi()
   if (res.code == 200) {
   if (res.code == 200) {
-    authOptions.value = res.data;
+    authOptions.value = res.data
   }
   }
-};
+}
 
 
 // 打开弹框
 // 打开弹框
-const open = async (type = "add") => {
-  mode.value = type;
+const open = async (type = 'add') => {
+  mode.value = type
   // 重置表单数据
   // 重置表单数据
-  Object.assign(formData, initialFormData);
-  formRef.value.clearValidate();
-  visible.value = true;
-  if (mode.value === "add") {
-    formData.auth_id = userStore.user.id;
+  Object.assign(formData, initialFormData)
+  formRef.value.clearValidate()
+  visible.value = true
+  if (mode.value === 'add') {
+    formData.auth_id = userStore.user.id
   }
   }
-  await initPage();
-};
+  await initPage()
+}
 
 
 // 初始化页面数据
 // 初始化页面数据
 const initPage = async () => {
 const initPage = async () => {
-  await getMediaOptions();
-  await getAgentOptions();
-  await getAuthList();
-};
+  await getMediaOptions()
+  await getAgentOptions()
+  await getAuthList()
+}
 
 
 // 设置数据
 // 设置数据
 const setFormData = async (data) => {
 const setFormData = async (data) => {
   for (const key in formData) {
   for (const key in formData) {
     if (data[key] != null && data[key] != undefined) {
     if (data[key] != null && data[key] != undefined) {
-      formData[key] = data[key];
+      formData[key] = data[key]
     }
     }
   }
   }
-};
+}
 
 
 // 数据保存
 // 数据保存
 const submit = async (done) => {
 const submit = async (done) => {
-  const validate = await formRef.value?.validate();
+  const validate = await formRef.value?.validate()
   if (!validate) {
   if (!validate) {
-    loading.value = true;
-    let data = { ...formData };
-    let result = {};
-    if (mode.value === "add") {
+    loading.value = true
+    let data = { ...formData }
+    let result = {}
+    if (mode.value === 'add') {
       // 添加数据
       // 添加数据
-      data.id = undefined;
-      result = await api.save(data);
+      data.id = undefined
+      result = await api.save(data)
     } else {
     } else {
       // 修改数据
       // 修改数据
-      result = await api.update(data.id, data);
+      result = await api.update(data.id, data)
     }
     }
     if (result.code === 200) {
     if (result.code === 200) {
-      Message.success("操作成功");
-      emit("success");
-      done(true);
+      Message.success('操作成功')
+      emit('success')
+      done(true)
     }
     }
     // 防止连续点击提交
     // 防止连续点击提交
     setTimeout(() => {
     setTimeout(() => {
-      loading.value = false;
-    }, 500);
+      loading.value = false
+    }, 500)
   }
   }
-  done(false);
-};
+  done(false)
+}
 
 
 // 关闭弹窗
 // 关闭弹窗
-const close = () => (visible.value = false);
+const close = () => (visible.value = false)
 
 
-defineExpose({ open, setFormData });
+defineExpose({ open, setFormData })
 </script>
 </script>

+ 1 - 1
src/views/v1/advert/agentSite/index.vue

@@ -106,7 +106,7 @@ const searchForm = ref({
   agent_id: '',
   agent_id: '',
 
 
   //默认当前登录的负责人
   //默认当前登录的负责人
-  auth_id: userStore.user.id,
+  auth_id: userStore.user.id == 1 ? [] : [userStore.user.id],
   name: '',
   name: '',
 })
 })