Răsfoiți Sursa

接口调试

zhangjie 1 an în urmă
părinte
comite
1c560e29e8

+ 1 - 0
package.json

@@ -31,6 +31,7 @@
     "nprogress": "^0.2.0",
     "pinia": "^2.0.27",
     "pinia-plugin-persistedstate": "^3.2.0",
+    "qs": "^6.11.2",
     "tdesign-vue-next": "^1.4.2",
     "tvision-color": "^1.5.0",
     "unplugin-vue-setup-extend-plus": "^1.0.0",

+ 11 - 17
src/api/system.js

@@ -1,4 +1,4 @@
-import { request } from '@/utils/request.js';
+import { request, paramsSerializer } from '@/utils/request.js';
 
 // customer-manage
 export const customeryQueryApi = (data) =>
@@ -183,30 +183,24 @@ export const noticeQueryApi = (data) =>
     params: data,
   });
 export const noticeEditApi = (data) => {
-  if (data.id) {
-    return request({
-      url: '/api/sys/notice/edit',
-      data,
-    });
-  } else {
-    return request({
-      url: '/api/sys/notice/add',
-      data,
-    });
-  }
+  return request({
+    url: '/api/sys/notice/save',
+    data,
+  });
 };
 export const noticePublishApi = (id) =>
   request({
-    url: '/api/sys/notice/publish',
+    url: '/api/sys/notice/publishOrUnpublish',
     params: { id },
   });
 export const noticeCancelPublishApi = (id) =>
   request({
-    url: '/api/sys/notice/cancel-publish',
+    url: '/api/sys/notice/publishOrUnpublish',
     params: { id },
   });
-export const noticeDestroyApi = (id) =>
+export const noticeDestroyApi = (ids) =>
   request({
-    url: '/api/sys/notice/destroy',
-    params: { id },
+    url: '/api/sys/notice/disable',
+    params: { ids },
+    paramsSerializer,
   });

+ 6 - 2
src/config/constants.js

@@ -16,7 +16,11 @@ export const RUNNING_STATUS = {
 };
 // 公告类型
 export const NOTICE_TYPE = {
-  COMMON: '公告',
-  SERVICE_UNIT: '服务单元通知',
+  SYSTEM: '公告',
+  SERVICE: '服务单元通知',
   SUPPLIER: '供应商通知',
 };
+export const PUBLISH_STATUS = {
+  PUBLISH: '已发布',
+  UN_PUBLISH: '未发布',
+};

+ 1 - 1
src/router/modules/myWorkbenches.js

@@ -52,7 +52,7 @@ export default {
           meta: {
             title: '通知公告',
             sort: 3,
-            alias: 'notice1',
+            alias: 'notice',
           },
         },
       ],

+ 1 - 1
src/router/modules/system.js

@@ -98,7 +98,7 @@ export default {
           meta: {
             title: '通知公告管理',
             sort: 1,
-            alias: 'notice',
+            alias: 'noticeManage',
           },
         },
         {

+ 4 - 0
src/utils/filter.js

@@ -3,6 +3,7 @@ import {
   SUPPLIER_TYPE,
   RUNNING_STATUS,
   NOTICE_TYPE,
+  PUBLISH_STATUS,
 } from '@/config/constants';
 import { dateFormat } from './tool';
 
@@ -28,3 +29,6 @@ export function runningStatusFilter(val) {
 export function noticeTypeFilter(val) {
   return NOTICE_TYPE[val] || DEFAULT_FIELD;
 }
+export function publishStatusFilter(val) {
+  return PUBLISH_STATUS[val] || DEFAULT_FIELD;
+}

+ 4 - 0
src/utils/request.js

@@ -138,6 +138,10 @@ function createRequest(service) {
   };
 }
 
+export function paramsSerializer(params) {
+  return qs.stringify(params);
+}
+
 // 用于真实网络请求的实例和请求方法
 export const service = createService();
 export const request = createRequest(service);

+ 24 - 18
src/views/system/notice-log/notice-manage/edit-notice-dialog.vue

@@ -22,20 +22,13 @@
           </t-form-item>
         </t-col>
         <t-col :span="6">
-          <t-form-item label="服务单元" name="unit">
-            <t-select v-model="formData.unit">
-              <t-option
-                v-for="(val, key) in NOTICE_TYPE"
-                :key="key"
-                :label="val"
-                :value="key"
-              />
-            </t-select>
+          <t-form-item label="服务单元" name="serviceId">
+            <t-select v-model="formData.serviceId"> </t-select>
           </t-form-item>
         </t-col>
         <t-col :span="12">
-          <t-form-item label="通知名称" name="name">
-            <t-input v-model="formData.name" clearable />
+          <t-form-item label="通知名称" name="title">
+            <t-input v-model="formData.title" clearable />
           </t-form-item>
         </t-col>
         <t-col :span="12">
@@ -53,7 +46,9 @@
       <t-button theme="default" @click="emit('update:visible', false)"
         >取消</t-button
       >
+      <t-button theme="primary" @click="onPreview">预览</t-button>
       <t-button theme="primary" @click="save">保存</t-button>
+      <t-button theme="primary" @click="save(true)">保存并发布</t-button>
     </template>
   </my-dialog>
 </template>
@@ -79,9 +74,10 @@ const { formData, isEdit } = useClearDialog(
   {
     id: null,
     type: '',
-    unit: '',
-    name: '',
+    serviceId: '1',
+    title: '',
     content: '',
+    status: 'UN_PUBLISH',
   },
   props,
   formRef,
@@ -92,7 +88,7 @@ const { formData, isEdit } = useClearDialog(
   }
 );
 const rules = {
-  name: [
+  title: [
     { required: true, message: '名称必填', type: 'error', trigger: 'change' },
     {
       max: 100,
@@ -104,7 +100,7 @@ const rules = {
   type: [
     { required: true, message: '类型必选', type: 'error', trigger: 'change' },
   ],
-  unit: [
+  serviceId: [
     {
       required: true,
       message: '服务单元必选',
@@ -122,12 +118,22 @@ const rules = {
     },
   ],
 };
-const save = async () => {
+const onPreview = () => {
+  console.log('onPreview');
+};
+
+const save = async (isPublish) => {
   const valid = await formRef.value.validate();
   if (valid !== true) return;
 
-  const res = await noticeEditApi(formData).catch(() => {});
-  if (!res) return;
+  let data = { ...formData };
+  data.status = isPublish ? 'PUBLISH' : 'UN_PUBLISH';
+
+  let result = true;
+  await noticeEditApi(data).catch(() => {
+    result = false;
+  });
+  if (!result) return;
 
   MessagePlugin.success('保存成功');
   emit('update:visible', false);

+ 91 - 59
src/views/system/notice-log/notice-manage/index.vue

@@ -28,6 +28,79 @@
         v-loading="tableLoading"
         @select-change="selectChange"
       >
+        <template #type="{ col, row }">
+          {{ noticeTypeFilter(row[col.colKey]) }}
+        </template>
+        <template #name="{ col, row }">
+          <span>{{ row.title }}</span>
+          <span>
+            【 {{ row.createName + ':'
+            }}{{
+              row.status === 'PUBLISH'
+                ? timestampFilter(row.publishTime)
+                : '暂未发布'
+            }}】
+          </span>
+        </template>
+        <template #status="{ col, row }">
+          {{ publishStatusFilter(row[col.colKey]) }}
+        </template>
+        <template #operate="{ col, row }">
+          <div class="table-operations">
+            <t-link
+              v-if="row.status === 'PUBLISH'"
+              theme="danger"
+              hover="color"
+              @click="
+                (e) => {
+                  e.stopPropagation();
+                  handleCancelPublish(row);
+                }
+              "
+            >
+              撤销发布
+            </t-link>
+            <t-link
+              v-else
+              theme="primary"
+              hover="color"
+              @click="
+                (e) => {
+                  e.stopPropagation();
+                  handlePublish(row);
+                }
+              "
+            >
+              发布
+            </t-link>
+            <t-link
+              v-if="row.status === 'PUBLISH'"
+              theme="primary"
+              hover="color"
+              @click="
+                (e) => {
+                  e.stopPropagation();
+                  handleFeedbackView(row);
+                }
+              "
+            >
+              回执查询
+            </t-link>
+            <t-link
+              v-if="row.status !== 'PUBLISH'"
+              theme="primary"
+              hover="color"
+              @click="
+                (e) => {
+                  e.stopPropagation();
+                  handleEdit(row);
+                }
+              "
+            >
+              修改
+            </t-link>
+          </div>
+        </template>
       </t-table>
     </div>
 
@@ -51,6 +124,13 @@ import {
   noticePublishApi,
   noticeCancelPublishApi,
 } from '@/api/system';
+import { dictToOptionList } from '@/utils/tool';
+import { NOTICE_TYPE, PUBLISH_STATUS } from '@/config/constants';
+import {
+  noticeTypeFilter,
+  publishStatusFilter,
+  timestampFilter,
+} from '@/utils/filter';
 
 const showEditNoticeDialog = ref(false);
 const curRow = ref(null);
@@ -63,10 +143,7 @@ const fields = ref([
     type: 'select',
     labelWidth: 100,
     colSpan: 5,
-    options: [
-      { value: 1, label: '已发布' },
-      { value: 2, label: '未发布' },
-    ],
+    options: dictToOptionList(PUBLISH_STATUS),
   },
   {
     prop: 'type',
@@ -74,7 +151,7 @@ const fields = ref([
     type: 'select',
     labelWidth: 60,
     colSpan: 5,
-    options: [{ value: 1, label: '公告' }],
+    options: dictToOptionList(NOTICE_TYPE),
   },
   {
     prop: 'publishTime',
@@ -126,61 +203,16 @@ const computedParams = computed(() => {
 
 const columns = [
   { colKey: 'row-select', type: 'multiple', width: 50 },
-  { colKey: 'type', title: '类型' },
-  { colKey: 'title', title: '消息名称' },
-  { colKey: 'status', title: '发布状态' },
+  { colKey: 'type', title: '类型', cell: 'type', width: 120 },
+  { colKey: 'title', title: '消息名称', cell: 'name' },
+  { colKey: 'status', title: '发布状态', cell: 'status', width: 100 },
   {
     title: '操作',
     colKey: 'operate',
     fixed: 'right',
-    width: 240,
+    width: 160,
     align: 'center',
-    cell: (h, { row }) => {
-      return (
-        <div class="table-operations">
-          <t-link
-            theme="primary"
-            hover="color"
-            onClick={(e) => {
-              e.stopPropagation();
-              handleCancelPublish(row);
-            }}
-          >
-            撤销发布
-          </t-link>
-          <t-link
-            theme="primary"
-            hover="color"
-            onClick={(e) => {
-              e.stopPropagation();
-              handlePublish(row);
-            }}
-          >
-            发布
-          </t-link>
-          <t-link
-            theme="primary"
-            hover="color"
-            onClick={(e) => {
-              e.stopPropagation();
-              handleFeedbackView(row);
-            }}
-          >
-            回执查询
-          </t-link>
-          <t-link
-            theme="primary"
-            hover="color"
-            onClick={(e) => {
-              e.stopPropagation();
-              handleEdit(row);
-            }}
-          >
-            修改
-          </t-link>
-        </div>
-      );
-    },
+    cell: 'operate',
   },
 ];
 const {
@@ -227,8 +259,8 @@ const handleDestroy = () => {
 };
 const handleCancelPublish = (row) => {
   const confirmDia = DialogPlugin({
-    header: '操作提示',
-    body: `确定要撤销发布当前信息吗`,
+    header: '撤销发布提示',
+    body: `您确定要撤销发布该通知公告吗?一旦撤销发布,该通知公告信息的回执将会被清空,重新发布后该通知公告将作为新消息发布。`,
     confirmBtn: '确定',
     cancelBtn: '取消',
     onConfirm: async () => {
@@ -249,8 +281,8 @@ const handleEdit = (row) => {
 };
 const handlePublish = (row) => {
   const confirmDia = DialogPlugin({
-    header: '操作提示',
-    body: `确定要发布当前信息吗`,
+    header: '发布提示',
+    body: `您确定要发布该通知公告吗?`,
     confirmBtn: '确定',
     cancelBtn: '取消',
     onConfirm: async () => {