Browse Source

修改智能客服问题回答

zs 1 year ago
parent
commit
24dd7945d2

+ 151 - 15
src/views/customer/intelligence/index.vue

@@ -2,40 +2,176 @@
   <div id="index">
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
-        <el-col :span="24" class="one"> 系统首页 </el-col>
+        <el-col :span="24" class="one">
+          <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch"> </cSearch>
+        </el-col>
+        <el-col :span="24" class="two">
+          <cButton @toAdd="toAdd()"> </cButton>
+        </el-col>
+        <el-col :span="24" class="thr">
+          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel">
+            <template #is_use="{ row }">
+              <el-switch
+                v-model="row.is_use"
+                inline-prompt
+                active-text="是"
+                inactive-text="否"
+                active-value="0"
+                inactive-value="1"
+                @click="handleChange(row)"
+              ></el-switch>
+            </template>
+          </cTable>
+        </el-col>
       </el-col>
     </el-row>
+    <cDialog :dialog="dialog" @toClose="toClose">
+      <template v-slot:info>
+        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
+          <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="toSave" label-width="auto">
+            <template #is_use>
+              <el-radio v-for="i in is_useList" :key="i._id" :label="i.value">{{ i.label }}</el-radio>
+            </template>
+          </cForm>
+        </el-col>
+      </template>
+    </cDialog>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
+import type { FormRules } from 'element-plus';
 import type { Ref } from 'vue';
-import { onMounted, ref } from 'vue';
-
+import { ref, onMounted, getCurrentInstance, reactive } from 'vue';
+import { ElMessage, ElMessageBox } from 'element-plus';
 // 接口
-// import { ToolsStore } from '@/stores/tool';
-// import type { IQueryResult } from '@/util/types.util';
-// const toolsAxios = ToolsStore();
-
+import { ProblemStore } from '@/stores/customer/problem';
+import { DictDataStore } from '@/stores/basic/dictData'; // 字典表
+import type { IQueryResult } from '@/util/types.util';
+const problemAxios = ProblemStore();
+const dictAxios = DictDataStore();
+const { proxy } = getCurrentInstance() as any;
 // 加载中
 const loading: Ref<any> = ref(false);
-
+let list: Ref<any> = ref([]);
+let total: Ref<number> = ref(0);
+let skip = 0;
+let limit: number = proxy.$limit;
+let fields: Ref<any[]> = ref([
+  { label: '问题', model: 'question', isSearch: true },
+  { label: '答案', model: 'answer' },
+  { label: '排序', model: 'sort', type: 'number' },
+  { label: '是否启用', model: 'is_use', custom: true }
+]);
+// 操作
+let opera: Ref<any[]> = ref([
+  { label: '修改', method: 'edit' },
+  { label: '删除', method: 'del', confirm: true, type: 'danger' }
+]);
+// 查询数据
+let searchForm: Ref<any> = ref({});
+// 字典表
+let is_useList: Ref<any> = ref([]);
+// 弹框
+const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
+const form: Ref<any> = ref({});
+const formFields: Ref<any> = ref([
+  { label: '问题', model: 'question' },
+  { label: '答案', model: 'answer', type: 'textarea' },
+  { label: '排序', model: 'sort', type: 'number' },
+  { label: '是否启用', model: 'is_use', type: 'radio' }
+]);
+const rules = reactive<FormRules>({
+  question: [{ required: true, message: '问题', trigger: 'blur' }],
+  answer: [{ required: true, message: '答案', trigger: 'blur' }],
+  sort: [{ required: true, message: '排序', trigger: 'blur' }]
+});
 // 请求
 onMounted(async () => {
   loading.value = true;
-  search();
+  await searchOther();
+  await search({ skip, limit });
   loading.value = false;
 });
-const search = async () => {
-  // let res: IQueryResult = await toolsAxios.dataCount();
-  // if (res.errcode == '0') {
-  //   info.value = res.data;
-  // }
+const search = async (e: { skip: number; limit: number }) => {
+  const info = { skip: e.skip, limit: e.limit, ...searchForm.value };
+  const res: IQueryResult = await problemAxios.query(info);
+  if (res.errcode == '0') {
+    list.value = res.data;
+    total.value = res.total;
+  }
+};
+const toSearch = (query: any) => {
+  searchForm.value = query;
+  search({ skip, limit });
+};
+// 提交保存
+const toSave = async (data: any) => {
+  let res: IQueryResult;
+  if (data._id) res = await problemAxios.update(data);
+  else res = await problemAxios.create(data);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `维护信息成功` });
+    toClose();
+  }
+};
+// 新增
+const toAdd = () => {
+  dialog.value = { title: '信息管理', show: true, type: '1' };
+};
+// 修改
+const toEdit = async (data: any) => {
+  let res: IQueryResult = await problemAxios.fetch(data._id);
+  if (res.errcode == '0') {
+    form.value = res.data;
+    dialog.value = { title: '信息管理', show: true, type: '1' };
+  }
+};
+// 删除
+const toDel = async (data: any) => {
+  let res: IQueryResult = await problemAxios.del(data._id);
+  if (res.errcode == 0) {
+    ElMessage({ type: `success`, message: `刪除信息成功` });
+    search({ skip, limit });
+  }
+};
+// 关闭弹框
+const toClose = () => {
+  form.value = {};
+  dialog.value = { show: false };
+  search({ skip, limit });
+};
+
+// 查询其他信息
+const searchOther = async () => {
+  let res: IQueryResult = await dictAxios.query({ type: 'is_use', is_use: '0' });
+  if (res.errcode == 0) is_useList.value = res.data;
+};
+// 修改是否启用
+const handleChange = (row: any) => {
+  const text = row.is_use === '0' ? '启用' : '停用';
+  ElMessageBox.confirm('确认要"' + text + '""' + row.question + '"吗?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  })
+    .then(async () => {
+      let res: IQueryResult;
+      if (row._id) res = await problemAxios.update(row);
+      if (res.errcode == 0) {
+        ElMessage({ type: `success`, message: `修改成功` });
+      }
+    })
+    .catch(() => {
+      row.is_use = row.is_use === '0' ? '1' : '0';
+    });
 };
 </script>
 <style scoped lang="scss">
 .main {
-  padding: 2px;
+  .two {
+    margin: 0 0 10px 0;
+  }
 }
 </style>

+ 15 - 151
src/views/customer/problem/index.vue

@@ -2,176 +2,40 @@
   <div id="index">
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
-        <el-col :span="24" class="one">
-          <cSearch :is_title="false" :is_search="true" :fields="fields" @search="toSearch"> </cSearch>
-        </el-col>
-        <el-col :span="24" class="two">
-          <cButton @toAdd="toAdd()"> </cButton>
-        </el-col>
-        <el-col :span="24" class="thr">
-          <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel">
-            <template #is_use="{ row }">
-              <el-switch
-                v-model="row.is_use"
-                inline-prompt
-                active-text="是"
-                inactive-text="否"
-                active-value="0"
-                inactive-value="1"
-                @click="handleChange(row)"
-              ></el-switch>
-            </template>
-          </cTable>
-        </el-col>
+        <el-col :span="24" class="one"> 系统首页 </el-col>
       </el-col>
     </el-row>
-    <cDialog :dialog="dialog" @toClose="toClose">
-      <template v-slot:info>
-        <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
-          <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="toSave" label-width="auto">
-            <template #is_use>
-              <el-radio v-for="i in is_useList" :key="i._id" :label="i.value">{{ i.label }}</el-radio>
-            </template>
-          </cForm>
-        </el-col>
-      </template>
-    </cDialog>
   </div>
 </template>
 
 <script setup lang="ts">
 // 基础
-import type { FormRules } from 'element-plus';
 import type { Ref } from 'vue';
-import { ref, onMounted, getCurrentInstance, reactive } from 'vue';
-import { ElMessage, ElMessageBox } from 'element-plus';
+import { onMounted, ref } from 'vue';
+
 // 接口
-import { ProblemStore } from '@/stores/customer/problem';
-import { DictDataStore } from '@/stores/basic/dictData'; // 字典表
-import type { IQueryResult } from '@/util/types.util';
-const problemAxios = ProblemStore();
-const dictAxios = DictDataStore();
-const { proxy } = getCurrentInstance() as any;
+// import { ToolsStore } from '@/stores/tool';
+// import type { IQueryResult } from '@/util/types.util';
+// const toolsAxios = ToolsStore();
+
 // 加载中
 const loading: Ref<any> = ref(false);
-let list: Ref<any> = ref([]);
-let total: Ref<number> = ref(0);
-let skip = 0;
-let limit: number = proxy.$limit;
-let fields: Ref<any[]> = ref([
-  { label: '问题', model: 'question', isSearch: true },
-  { label: '答案', model: 'answer' },
-  { label: '排序', model: 'sort', type: 'number' },
-  { label: '是否启用', model: 'is_use', custom: true }
-]);
-// 操作
-let opera: Ref<any[]> = ref([
-  { label: '修改', method: 'edit' },
-  { label: '删除', method: 'del', confirm: true, type: 'danger' }
-]);
-// 查询数据
-let searchForm: Ref<any> = ref({});
-// 字典表
-let is_useList: Ref<any> = ref([]);
-// 弹框
-const dialog: Ref<any> = ref({ title: '信息管理', show: false, type: '1' });
-const form: Ref<any> = ref({});
-const formFields: Ref<any> = ref([
-  { label: '问题', model: 'question' },
-  { label: '答案', model: 'answer', type: 'textarea' },
-  { label: '排序', model: 'sort', type: 'number' },
-  { label: '是否启用', model: 'is_use', type: 'radio' }
-]);
-const rules = reactive<FormRules>({
-  question: [{ required: true, message: '问题', trigger: 'blur' }],
-  answer: [{ required: true, message: '答案', trigger: 'blur' }],
-  sort: [{ required: true, message: '排序', trigger: 'blur' }]
-});
+
 // 请求
 onMounted(async () => {
   loading.value = true;
-  await searchOther();
-  await search({ skip, limit });
+  search();
   loading.value = false;
 });
-const search = async (e: { skip: number; limit: number }) => {
-  const info = { skip: e.skip, limit: e.limit, ...searchForm.value };
-  const res: IQueryResult = await problemAxios.query(info);
-  if (res.errcode == '0') {
-    list.value = res.data;
-    total.value = res.total;
-  }
-};
-const toSearch = (query: any) => {
-  searchForm.value = query;
-  search({ skip, limit });
-};
-// 提交保存
-const toSave = async (data: any) => {
-  let res: IQueryResult;
-  if (data._id) res = await problemAxios.update(data);
-  else res = await problemAxios.create(data);
-  if (res.errcode == 0) {
-    ElMessage({ type: `success`, message: `维护信息成功` });
-    toClose();
-  }
-};
-// 新增
-const toAdd = () => {
-  dialog.value = { title: '信息管理', show: true, type: '1' };
-};
-// 修改
-const toEdit = async (data: any) => {
-  let res: IQueryResult = await problemAxios.fetch(data._id);
-  if (res.errcode == '0') {
-    form.value = res.data;
-    dialog.value = { title: '信息管理', show: true, type: '1' };
-  }
-};
-// 删除
-const toDel = async (data: any) => {
-  let res: IQueryResult = await problemAxios.del(data._id);
-  if (res.errcode == 0) {
-    ElMessage({ type: `success`, message: `刪除信息成功` });
-    search({ skip, limit });
-  }
-};
-// 关闭弹框
-const toClose = () => {
-  form.value = {};
-  dialog.value = { show: false };
-  search({ skip, limit });
-};
-
-// 查询其他信息
-const searchOther = async () => {
-  let res: IQueryResult = await dictAxios.query({ type: 'is_use', is_use: '0' });
-  if (res.errcode == 0) is_useList.value = res.data;
-};
-// 修改是否启用
-const handleChange = (row: any) => {
-  const text = row.is_use === '0' ? '启用' : '停用';
-  ElMessageBox.confirm('确认要"' + text + '""' + row.question + '"吗?', '提示', {
-    confirmButtonText: '确定',
-    cancelButtonText: '取消',
-    type: 'warning'
-  })
-    .then(async () => {
-      let res: IQueryResult;
-      if (row._id) res = await problemAxios.update(row);
-      if (res.errcode == 0) {
-        ElMessage({ type: `success`, message: `修改成功` });
-      }
-    })
-    .catch(() => {
-      row.is_use = row.is_use === '0' ? '1' : '0';
-    });
+const search = async () => {
+  // let res: IQueryResult = await toolsAxios.dataCount();
+  // if (res.errcode == '0') {
+  //   info.value = res.data;
+  // }
 };
 </script>
 <style scoped lang="scss">
 .main {
-  .two {
-    margin: 0 0 10px 0;
-  }
+  padding: 2px;
 }
 </style>

+ 1 - 2
src/views/problem/opinion/index.vue

@@ -15,8 +15,7 @@
         <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
           <cForm :span="24" :fields="formFields" :form="form" :rules="{}" :isSave="true" :disabled="true">
             <template #file>
-              <cUpload :model="`${'file'}`" :limit="1" listType="picture-card" url="/files/travel/opinion/upload"
-                accept="*" :list="form.file"></cUpload>
+              <cUpload :model="`${'file'}`" :limit="1" listType="picture-card" url="/files/travel/opinion/upload" accept="*" :list="form.file"></cUpload>
             </template>
           </cForm>
         </el-col>