2 Commits 0b8945e9d2 ... b9f98e6abc

Autore SHA1 Messaggio Data
  ZaiZai b9f98e6abc Merge remote-tracking branch 'origin/main' 1 mese fa
  ZaiZai 58cf2d2586 系统公告 1 mese fa
1 ha cambiato i file con 220 aggiunte e 4 eliminazioni
  1. 220 4
      src/views/system/notice.vue

+ 220 - 4
src/views/system/notice.vue

@@ -59,7 +59,7 @@
         </template>
 
         <!-- 待发布 -->
-        <hc-dialog v-model="isReleasedShow" title="待发布的公告" class="hc-system-announcement-dialog black-card" widths="660px" :footer="false" @close="releasedCancel">
+        <hc-dialog v-model="isReleasedShow" title="待发布的公告" ui="hc-system-announcement-dialog black-card" widths="660px" :footer="false" @close="releasedCancel">
             <el-divider v-if="releasedData.updateMsg.length > 0" content-position="left" class="hc-system-announcement-black-divider top">更新公告</el-divider>
             <div v-for="(item, index) in releasedData.updateMsg" :key="index" class="hc-system-announcement-black-card">
                 <div class="icon-box">
@@ -111,12 +111,93 @@
                 </div>
             </div>
         </hc-dialog>
+
+
+        <!-- 发布普通公告 -->
+        <hc-dialog v-model="isGeneralShow" widths="700px" ui="hc-system-announcement-dialog" is-footer-center title="发布普通公告" @close="generalCancel">
+            <el-form ref="generalFormRef" :model="generalFormModel" :rules="generalFormRules" class="hc-system-announcement-form" label-width="auto">
+                <el-form-item label="公告内容:" prop="msgContent">
+                    <el-input v-model="generalFormModel.msgContent" type="textarea" />
+                </el-form-item>
+                <el-form-item label="发布备注:" prop="pushRemark">
+                    <el-input v-model="generalFormModel.pushRemark" type="textarea" />
+                </el-form-item>
+                <el-form-item label="发布配置:" prop="pushDateTime">
+                    <el-date-picker v-model="generalFormModel.pushDateTime" type="datetime" placeholder="选择日期时间" :picker-options="pickerOptions" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" />
+                </el-form-item>
+                <el-form-item label="停留时间:" prop="msgShowTime">
+                    <el-select v-model="generalFormModel.msgShowTime" clearable filterable style="width: 190px;">
+                        <el-option v-for="i in 60" :key="i" :label="`${i}分钟`" :value="i" />
+                    </el-select>
+                </el-form-item>
+                <el-form-item label="涉及系统:" prop="pushSystem">
+                    <el-checkbox-group v-model="generalFormModel.pushSystem">
+                        <el-checkbox v-for="item in systemClinet" :key="item.clientId" :value="item.clientId">{{ item.name || item.clientId }}</el-checkbox>
+                    </el-checkbox-group>
+                </el-form-item>
+            </el-form>
+            <template #footer>
+                <el-button hc-btn @click="generalCancel">取消</el-button>
+                <el-button hc-btn type="primary" @click="generalFormSubmit">提交</el-button>
+            </template>
+        </hc-dialog>
+
+        <!-- 发布系统公告 -->
+        <hc-dialog v-model="isSystemUpdateShow" widths="700px" ui="hc-system-announcement-dialog" is-footer-center title="发布系统公告" @close="systemUpdateCancel">
+            <el-form ref="updateFormRef" :model="updateFormModel" :rules="updateFormRules" class="hc-system-announcement-form" label-width="auto">
+                <el-form-item label="公告内容:" prop="msgContent">
+                    <el-input v-model="updateFormModel.msgContent" type="textarea" />
+                </el-form-item>
+                <el-form-item label="发布备注:" prop="pushRemark">
+                    <el-input v-model="updateFormModel.pushRemark" type="textarea" />
+                </el-form-item>
+                <el-form-item label="更新类型:" prop="updateServerType">
+                    <el-checkbox-group v-model="updateFormModel.updateServerType">
+                        <el-checkbox value="1">前端页面</el-checkbox>
+                        <el-checkbox value="2">后端接口</el-checkbox>
+                    </el-checkbox-group>
+                </el-form-item>
+                <el-form-item label="更新原因:" prop="updateCodeType">
+                    <el-radio-group v-model="updateFormModel.updateCodeType">
+                        <el-radio value="1">新功能需求</el-radio>
+                        <el-radio value="2">bug修复</el-radio>
+                    </el-radio-group>
+                </el-form-item>
+                <el-form-item label="发布配置:" prop="pushDateTime">
+                    <el-date-picker v-model="updateFormModel.pushDateTime" type="datetime" placeholder="选择日期时间" :picker-options="pickerOptions" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" />
+                </el-form-item>
+                <el-form-item label="时间配置:" prop="msgWarnTime">
+                    <span>剩余</span>
+                    <span style="margin-left: 5px">
+                        <el-select v-model="updateFormModel.msgWarnTime" clearable filterable size="small" style="width: 90px;" placeholder="分钟">
+                            <el-option v-for="i in 60" :key="i" :label="`${i}分钟`" :value="i" />
+                        </el-select>
+                    </span>
+                    <span style="margin-left: 5px">进行提醒,</span>
+                    <span style="margin-left: 5px">
+                        <el-select v-model="updateFormModel.msgCountDownTime" clearable filterable size="small" style="width: 90px;" placeholder="时间">
+                            <el-option v-for="i in 60" :key="i" :label="`${i}分钟`" :value="i" />
+                        </el-select>
+                    </span>
+                    <span style="margin-left: 5px">开始进入倒计时</span>
+                </el-form-item>
+                <el-form-item label="涉及系统:" prop="pushSystem">
+                    <el-checkbox-group v-model="updateFormModel.pushSystem">
+                        <el-checkbox v-for="item in systemClinet" :key="item.clientId" :value="item.clientId">{{ item.name || item.clientId }}</el-checkbox>
+                    </el-checkbox-group>
+                </el-form-item>
+            </el-form>
+            <template #footer>
+                <el-button hc-btn @click="systemUpdateCancel">取消</el-button>
+                <el-button hc-btn type="primary" @click="updateFormSubmit">发布</el-button>
+            </template>
+        </hc-dialog>
     </hc-card>
 </template>
 
 <script setup>
 import { onActivated, ref } from 'vue'
-import { arrToId, getArrValue, getObjValue } from 'js-fast-way'
+import { arrToId, deepClone, formValidate, getArrValue, getObjValue } from 'js-fast-way'
 import { reloadPage } from '~uti/tools'
 import { HcDelMsg } from 'hc-vue3-ui'
 import mainApi from '~api/system/notice'
@@ -198,7 +279,17 @@ const tableCheckChange = (rows) => {
 
 //修改
 const handleEdit = (row) => {
-
+    const form = deepClone(row)
+    if (form.msgType === 1) {
+        form.updateServerType = form.updateServerType.split(',')
+        form.pushSystem = form.pushSystem.split(',')
+        updateFormModel.value = form
+        systemUpdateShow()
+    } else {
+        form.pushSystem = form.pushSystem.split(',')
+        generalFormModel.value = form
+        generalShow()
+    }
 }
 
 //取消发布
@@ -213,19 +304,144 @@ const isReleasedShow = ref(false)
 const releasedShow = () => {
     isReleasedShow.value = true
 }
-
 const releasedCancel = () => {
     isReleasedShow.value = false
 }
 
+const isGeneralShow = ref(false)
+const generalFormRef = ref(null)
+const generalFormModel = ref({})
+const generalFormRules = {
+    msgContent: { required: true, trigger: 'blur', message: '请填写公告内容' },
+    pushDateTime: { required: true, trigger: 'blur', message: '请选择发布配置' },
+    msgShowTime: { required: true, trigger: 'blur', message: '请选择停留时间' },
+    pushSystem: { required: true, trigger: 'blur', message: '请选择涉及系统' },
+}
+
+//获取应用列表
+const systemClinet = ref([])
+const getClinetAllApi = async () => {
+    const { data } = await mainApi.getClinetAll()
+    systemClinet.value = getArrValue(data)
+}
+
 //发布普通公告
 const generalShow = () => {
+    isGeneralShow.value = true
+    getClinetAllApi()
+}
+
+const generalFormSubmit = async () => {
+    const formRes = await formValidate(generalFormRef.value)
+    if (!formRes) return false
+    let form = deepClone(generalFormModel.value)
+    form.pushSystem = form.pushSystem.join(',')
+    form.msgType = 2
+    if (form.id) {
+        const { isRes, msg } = await mainApi.update(form)
+        if (!isRes) return
+        this.$message.success(msg || '操作成功')
+        reloadPage()
+    } else {
+        const { isRes, msg } = await mainApi.add(form)
+        if (!isRes) return
+        this.$message.success(msg || '操作成功')
+        reloadPage()
+    }
+}
 
+const generalCancel = () => {
+    isGeneralShow.value = false
+    generalFormModel.value = {}
 }
 
+const isSystemUpdateShow = ref(false)
+const updateFormRef = ref(null)
+const updateFormModel = ref({})
+const updateFormRules = {
+    msgContent: { required: true, trigger: 'blur', message: '请填写公告内容' },
+    updateServerType: { required: true, trigger: 'blur', message: '请选择更新类型' },
+    updateCodeType: { required: true, trigger: 'blur', message: '请选择更新原因' },
+    pushDateTime: {
+        required: true,
+        validator: (rule, value, callback) => {
+            const { msgWarnTime } = updateFormModel.value
+            if (!value) {
+                callback(new Error('请选择发布配置'))
+            } else if (!msgWarnTime) {
+                callback(new Error('请选择时间配置'))
+            } else {
+                callback()
+            }
+        },
+    },
+    msgWarnTime: { required: true, trigger: 'blur', message: '请选择时间配置' },
+    pushSystem: { required: true, trigger: 'blur', message: '请选择涉及系统' },
+}
+
+
 //发布系统公告
 const systemUpdateShow = () => {
+    isSystemUpdateShow.value = true
+    getClinetAllApi()
+}
+
+const updateFormSubmit = async () => {
+    const formRes = await formValidate(updateFormModel.value)
+    if (!formRes) return false
+    let form = deepClone(updateFormModel.value)
+    form.pushSystem = form.pushSystem.join(',')
+    form.updateServerType = form.updateServerType.join(',')
+    form.msgType = 1
+    if (form.id) {
+        const { isRes, msg } = await mainApi.update(form)
+        if (!isRes) return
+        this.$message.success(msg || '操作成功')
+        reloadPage()
+    } else {
+        const { isRes, msg } = await mainApi.add(form)
+        if (!isRes) return
+        this.$message.success(msg || '操作成功')
+        reloadPage()
+    }
+}
+
+const systemUpdateCancel = () => {
+    isSystemUpdateShow.value = false
+    updateFormModel.value = {}
+}
 
+//日期时间
+const pickerOptions = {
+    shortcuts: [{
+        text: '三分钟',
+        onClick(picker) {
+            const date = new Date()
+            date.setTime(date.getTime() + 3 * 60 * 1000)
+            picker.$emit('pick', date)
+        },
+    }, {
+        text: '五分钟',
+        onClick(picker) {
+            const date = new Date()
+            date.setTime(date.getTime() + 5 * 60 * 1000)
+            picker.$emit('pick', date)
+        },
+    }, {
+        text: '十分钟',
+        onClick(picker) {
+            const date = new Date()
+            date.setTime(date.getTime() + 10 * 60 * 1000)
+            picker.$emit('pick', date)
+        },
+    }, {
+        text: '三十分钟',
+        onClick(picker) {
+            const date = new Date()
+            date.setTime(date.getTime() + 30 * 60 * 1000)
+            picker.$emit('pick', date)
+        },
+    }],
 }
 
 //批量删除公告