Compare commits
	
		
			9 Commits
		
	
	
		
			master
			...
			8809dbe59d
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 8809dbe59d | |||
| fa46454638 | |||
| e67b03d8a7 | |||
| f57e22d74f | |||
| 71ad46e43c | |||
| 5df11417b2 | |||
| c8e64a1abf | |||
| fe816585f0 | |||
| ba45ca26bb | 
@@ -2,7 +2,8 @@ ENV = 'development'
 | 
			
		||||
VITE_CLI_PORT = 8088
 | 
			
		||||
VITE_SERVER_PORT = 8888
 | 
			
		||||
VITE_BASE_API = /api
 | 
			
		||||
VITE_BASE_PATH = http://4a1840b2.r12.cpolar.top
 | 
			
		||||
// VITE_BASE_PATH = https://api.jimingyiliao.com/
 | 
			
		||||
VITE_BASE_PATH = https://367a21fd.r12.cpolar.top 
 | 
			
		||||
VITE_EDITOR = vscode
 | 
			
		||||
// VITE_EDITOR = webstorm 如果使用webstorm开发且要使用dom定位到代码行功能 请先自定添加 webstorm到环境变量 再将VITE_EDITOR值修改为webstorm
 | 
			
		||||
// 如果使用docker-compose开发模式,设置为下面的地址或本机主机IP
 | 
			
		||||
 
 | 
			
		||||
@@ -4,5 +4,5 @@ VITE_CLI_PORT = 8080
 | 
			
		||||
VITE_SERVER_PORT = 8888
 | 
			
		||||
VITE_BASE_API = /api
 | 
			
		||||
#下方修改为你的线上ip
 | 
			
		||||
VITE_BASE_PATH = http://36b924d2.r12.cpolar.top 
 | 
			
		||||
VITE_BASE_PATH = https://api.jimingyiliao.com/
 | 
			
		||||
//VITE_BASE_PATH = http://36b924d2.r12.cpolar.top 
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -19,6 +19,7 @@
 | 
			
		||||
        "element-plus": "2.2.9",
 | 
			
		||||
        "highlight.js": "^10.6.0",
 | 
			
		||||
        "js-cookie": "^3.0.1",
 | 
			
		||||
        "lodash": "^4.17.21",
 | 
			
		||||
        "marked": "^2.0.0",
 | 
			
		||||
        "mitt": "^3.0.0",
 | 
			
		||||
        "nprogress": "^0.2.0",
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@
 | 
			
		||||
    "element-plus": "2.2.9",
 | 
			
		||||
    "highlight.js": "^10.6.0",
 | 
			
		||||
    "js-cookie": "^3.0.1",
 | 
			
		||||
    "lodash": "^4.17.21",
 | 
			
		||||
    "marked": "^2.0.0",
 | 
			
		||||
    "mitt": "^3.0.0",
 | 
			
		||||
    "nprogress": "^0.2.0",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										33
									
								
								src/api/aiList.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/api/aiList.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
import service from '@/utils/request'
 | 
			
		||||
const api = {
 | 
			
		||||
  // AI 列表api
 | 
			
		||||
  getAiList: data => {
 | 
			
		||||
    return service({
 | 
			
		||||
      url: '/aikefu/list',
 | 
			
		||||
      method: 'get',
 | 
			
		||||
      params: data
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  addAi: data => {
 | 
			
		||||
    return service({
 | 
			
		||||
      url: '/aikefu',
 | 
			
		||||
      method: 'post',
 | 
			
		||||
      data
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  editAi: data => {
 | 
			
		||||
    return service({
 | 
			
		||||
      url: '/aikefu',
 | 
			
		||||
      method: 'put',
 | 
			
		||||
      data
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  deleteFunc: data => {
 | 
			
		||||
    return service({
 | 
			
		||||
      url: '/aikefu',
 | 
			
		||||
      method: 'delete',
 | 
			
		||||
      data
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
export default api
 | 
			
		||||
							
								
								
									
										40
									
								
								src/api/bgList.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/api/bgList.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
import service from '@/utils/request'
 | 
			
		||||
const api = {
 | 
			
		||||
  // 背景图api
 | 
			
		||||
  getBgManageList: data => {
 | 
			
		||||
    return service({
 | 
			
		||||
      url: '/poster/list',
 | 
			
		||||
      method: 'get',
 | 
			
		||||
      params: data
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  addBgManage: data => {
 | 
			
		||||
    return service({
 | 
			
		||||
      url: '/poster',
 | 
			
		||||
      method: 'post',
 | 
			
		||||
      data
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  editBgManage: data => {
 | 
			
		||||
    return service({
 | 
			
		||||
      url: '/poster',
 | 
			
		||||
      method: 'put',
 | 
			
		||||
      data
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  delBg: data => {
 | 
			
		||||
    return service({
 | 
			
		||||
      url: '/poster',
 | 
			
		||||
      method: 'delete',
 | 
			
		||||
      data
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
  editBgState: data => {
 | 
			
		||||
    return service({
 | 
			
		||||
      url: '/banner/status',
 | 
			
		||||
      method: 'put',
 | 
			
		||||
      data
 | 
			
		||||
    })
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
export default api
 | 
			
		||||
@@ -3,7 +3,9 @@
 | 
			
		||||
 * @params file File类型的图片文件
 | 
			
		||||
 * @return Promise<file> 返回一个promise,值为一个压缩后的图片文件
 | 
			
		||||
 */
 | 
			
		||||
import { getToken } from '@/utils/auth'
 | 
			
		||||
import { ref } from 'vue'
 | 
			
		||||
// import { getToken } from '@/utils/auth'
 | 
			
		||||
const getToken = localStorage.getItem('token')
 | 
			
		||||
function imgCutdown(file) {
 | 
			
		||||
  return new Promise((resolve) => {
 | 
			
		||||
    const render = new FileReader();
 | 
			
		||||
@@ -50,11 +52,12 @@ function imgCutdown(file) {
 | 
			
		||||
    render.readAsDataURL(file);
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const path = ref(import.meta.env.VITE_BASE_API)
 | 
			
		||||
// 上传图片的地址,我这里使用的是vue的环境变量,也可以直接写死
 | 
			
		||||
// const uploadUrl = `${process.env.VUE_APP_HOST}image/upload.do`;
 | 
			
		||||
// const uploadUrl = `https://192.168.1.23:8000/api/v1/public/uploadFile`
 | 
			
		||||
const uploadUrl = `https://apiwx.twzxjy.com/api/v1/public/uploadFile`
 | 
			
		||||
// const uploadUrl = `https://apiwx.twzxjy.com/api/v1/public/uploadFile`
 | 
			
		||||
const uploadUrl = `${path.value}/fileUploadAndDownload/upload`
 | 
			
		||||
 | 
			
		||||
// 自定义适配器类
 | 
			
		||||
class MyUploadAdapter {
 | 
			
		||||
@@ -83,7 +86,8 @@ class MyUploadAdapter {
 | 
			
		||||
    const xhr = (this.xhr = new XMLHttpRequest())
 | 
			
		||||
 | 
			
		||||
    xhr.open('POST', uploadUrl, true)
 | 
			
		||||
    xhr.setRequestHeader('Authorization', 'Bearer ' + getToken())
 | 
			
		||||
    // xhr.setRequestHeader('Authorization', 'Bearer ' + getToken())
 | 
			
		||||
    xhr.setRequestHeader('X-token', getToken)
 | 
			
		||||
    xhr.responseType = 'json'
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -102,10 +106,11 @@ class MyUploadAdapter {
 | 
			
		||||
          response && response.error ? response.error.message : genericErrorText
 | 
			
		||||
        )
 | 
			
		||||
      }
 | 
			
		||||
      console.log(response)
 | 
			
		||||
      console.log('response is ======', response)
 | 
			
		||||
 | 
			
		||||
      resolve({
 | 
			
		||||
        default: response.data.path,
 | 
			
		||||
        // default: response.data.path,
 | 
			
		||||
        default: response.data.file.url,
 | 
			
		||||
      })
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@
 | 
			
		||||
                margin: 30px 0;
 | 
			
		||||
                .login_panel_form_title_logo {
 | 
			
		||||
                    width: 90px;
 | 
			
		||||
                    height: 72px;
 | 
			
		||||
                    height: 90px;
 | 
			
		||||
                }
 | 
			
		||||
                .login_panel_form_title_p {
 | 
			
		||||
                    font-size: 40px;
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,6 @@ import { ElMessage, ElMessageBox } from 'element-plus'
 | 
			
		||||
import { useUserStore } from '@/pinia/modules/user'
 | 
			
		||||
import { emitter } from '@/utils/bus.js'
 | 
			
		||||
import router from '@/router/index'
 | 
			
		||||
 | 
			
		||||
const service = axios.create({
 | 
			
		||||
  baseURL: import.meta.env.VITE_BASE_API,
 | 
			
		||||
  timeout: 99999
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										374
									
								
								src/view/aiList/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										374
									
								
								src/view/aiList/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,374 @@
 | 
			
		||||
 | 
			
		||||
<script setup>
 | 
			
		||||
// 引入依赖
 | 
			
		||||
import api from '@/api/aiList'
 | 
			
		||||
// import capi from '@/api/course'
 | 
			
		||||
// import custom from '@/utils/custom'
 | 
			
		||||
import { formatDate } from '@/utils/format'
 | 
			
		||||
import _ from 'lodash'
 | 
			
		||||
// import { toSQLLine } from '@/utils/stringFun'
 | 
			
		||||
// import WarningBar from '@/components/warningBar/warningBar.vue'
 | 
			
		||||
import ckEditor from '@/components/richText/ckEditor5.vue'
 | 
			
		||||
import { ref, onMounted } from 'vue'
 | 
			
		||||
import { ElMessage, ElMessageBox } from 'element-plus'
 | 
			
		||||
import { useRouter, useRoute } from 'vue-router'
 | 
			
		||||
const router = useRouter()
 | 
			
		||||
const route = useRoute()
 | 
			
		||||
const path = ref(import.meta.env.VITE_BASE_API)
 | 
			
		||||
import { useUserStore } from '@/pinia/modules/user'
 | 
			
		||||
const userStore = useUserStore()
 | 
			
		||||
// 变量
 | 
			
		||||
// const typeList = custom.getExercisesTypeList()
 | 
			
		||||
const queryParams = ref({
 | 
			
		||||
  page: 1,
 | 
			
		||||
  pageSize: 10,
 | 
			
		||||
  key_word: '',
 | 
			
		||||
  // name: '',
 | 
			
		||||
  // type: '',
 | 
			
		||||
  // subject: ''
 | 
			
		||||
})
 | 
			
		||||
// const subjectParams = ref({
 | 
			
		||||
//   page: 1,
 | 
			
		||||
//   pageSize: 100,
 | 
			
		||||
// })
 | 
			
		||||
const tableData = ref([])
 | 
			
		||||
// const subjectList = ref([])
 | 
			
		||||
const deleteVisible = ref(false)
 | 
			
		||||
const question_ids = ref([])
 | 
			
		||||
const total = ref(0)
 | 
			
		||||
const dialogFormVisible = ref(false)
 | 
			
		||||
const dialogTitle = ref('')
 | 
			
		||||
const form = ref({})
 | 
			
		||||
const rules = ref({
 | 
			
		||||
  key_word: [{ required: true, message: '请输入关键词', trigger: 'blur' }],
 | 
			
		||||
  content: [{ required: true, message: '请输入内容', trigger: 'blur' }],
 | 
			
		||||
//   linke_title: [{ required: true, message: '请输入其他关键词', trigger: 'blur' }]
 | 
			
		||||
})
 | 
			
		||||
// const question_id = ref(0)
 | 
			
		||||
// const content = ref(null)
 | 
			
		||||
// const options = ref([]) // 答案选项数组
 | 
			
		||||
const question_form = ref({
 | 
			
		||||
  options: [],
 | 
			
		||||
  answer: '',
 | 
			
		||||
  title: ''
 | 
			
		||||
})
 | 
			
		||||
// 生命周期
 | 
			
		||||
onMounted(() => {
 | 
			
		||||
  getAiList()
 | 
			
		||||
  // getSubject()
 | 
			
		||||
})
 | 
			
		||||
// 方法
 | 
			
		||||
async function getAiList() {
 | 
			
		||||
  const res = await api.getAiList(queryParams.value)
 | 
			
		||||
  if (res.code === 0) {
 | 
			
		||||
    tableData.value = res.data.list
 | 
			
		||||
    console.log(tableData.value)
 | 
			
		||||
    total.value = res.data.total
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
// async function getSubject() { // 获取课程分类
 | 
			
		||||
//     const res = await capi.getSubjectList(subjectParams.value)
 | 
			
		||||
//     if (res.code === 0) {
 | 
			
		||||
//         subjectList.value = custom.getStdSubject(res.data.records)
 | 
			
		||||
//     }
 | 
			
		||||
// }
 | 
			
		||||
function onSubmit() {
 | 
			
		||||
  getAiList()
 | 
			
		||||
}
 | 
			
		||||
const onReset = () => {
 | 
			
		||||
  queryParams.value = {
 | 
			
		||||
    page: 1,
 | 
			
		||||
    pageSize: 10,
 | 
			
		||||
    name: '',
 | 
			
		||||
    // status: '',
 | 
			
		||||
    // subject: ''
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
function openDialog(type) {
 | 
			
		||||
  // let params = {}
 | 
			
		||||
  switch (type) {
 | 
			
		||||
    case 'add':
 | 
			
		||||
      dialogTitle.value = '新增文章'
 | 
			
		||||
      form.value = {}
 | 
			
		||||
      break
 | 
			
		||||
    case 'edit':
 | 
			
		||||
      // params.question_id = question_id.value
 | 
			
		||||
      dialogTitle.value = '编辑文章'
 | 
			
		||||
      break
 | 
			
		||||
  }
 | 
			
		||||
  dialogFormVisible.value = true
 | 
			
		||||
  // router.push({name:'addCourse',params})
 | 
			
		||||
}
 | 
			
		||||
async function onDelete() {
 | 
			
		||||
  const ids = question_ids.value.map(item => item.question_id)
 | 
			
		||||
  const res = await api.delExercises({ question_ids: ids })
 | 
			
		||||
  if (res.code === 0) {
 | 
			
		||||
    ElMessage({
 | 
			
		||||
      type: 'success',
 | 
			
		||||
      message: res.msg
 | 
			
		||||
    })
 | 
			
		||||
    // if (tableData.value.length === ids.length && page.value > 1) {
 | 
			
		||||
    //   page.value--
 | 
			
		||||
    // }
 | 
			
		||||
    deleteVisible.value = false
 | 
			
		||||
    getAiList()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
const handleSelectionChange = (val) => {
 | 
			
		||||
  question_ids.value = val
 | 
			
		||||
}
 | 
			
		||||
function editFunc(row) {
 | 
			
		||||
  form.value = _.cloneDeep(row)
 | 
			
		||||
  // question_id.value = form.value.question_id
 | 
			
		||||
  // content.value = JSON.parse(form.value.question).title
 | 
			
		||||
  // question_form.value = JSON.parse(form.value.question)
 | 
			
		||||
  // if (!question_form.value.options) {
 | 
			
		||||
  //   question_form.value.options = []
 | 
			
		||||
  // }
 | 
			
		||||
  openDialog('edit')
 | 
			
		||||
}
 | 
			
		||||
function deleteFunc(row) {
 | 
			
		||||
  ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
 | 
			
		||||
    confirmButtonText: '确定',
 | 
			
		||||
    cancelButtonText: '取消',
 | 
			
		||||
    type: 'warning'
 | 
			
		||||
  })
 | 
			
		||||
    .then(async () => {
 | 
			
		||||
      const res = await api.deleteFunc({
 | 
			
		||||
        id: row.ID
 | 
			
		||||
      })
 | 
			
		||||
      if (res.code === 0) {
 | 
			
		||||
        ElMessage({
 | 
			
		||||
          type: 'success',
 | 
			
		||||
          message: '删除成功!'
 | 
			
		||||
        })
 | 
			
		||||
        getAiList()
 | 
			
		||||
      }
 | 
			
		||||
    }, () => {
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
function handleCurrentChange(val) {
 | 
			
		||||
  queryParams.value.page = val
 | 
			
		||||
  getAiList()
 | 
			
		||||
}
 | 
			
		||||
function handleSizeChange(val) {
 | 
			
		||||
  queryParams.value.pageSize = val
 | 
			
		||||
  getAiList()
 | 
			
		||||
}
 | 
			
		||||
function closeDialog() {
 | 
			
		||||
  dialogFormVisible.value = false
 | 
			
		||||
  question_form.value = {
 | 
			
		||||
    options: [],
 | 
			
		||||
    answer: '',
 | 
			
		||||
    title: ''
 | 
			
		||||
  }
 | 
			
		||||
  form.value = {}
 | 
			
		||||
}
 | 
			
		||||
async function enterDialog() { // 提交
 | 
			
		||||
  //   form.value.score = parseInt(form.value.score)
 | 
			
		||||
  //   form.value.teacher_id = 0
 | 
			
		||||
  //   form.value.question = JSON.stringify(question_form.value)
 | 
			
		||||
  let func_name = 'addAi'
 | 
			
		||||
  if (form.value.ID) { // 编辑
 | 
			
		||||
    func_name = 'editAi'
 | 
			
		||||
  }
 | 
			
		||||
  const res = await api[func_name](form.value)
 | 
			
		||||
  if (res.code === 0) {
 | 
			
		||||
    ElMessage({
 | 
			
		||||
      type: 'success',
 | 
			
		||||
      message: res.msg
 | 
			
		||||
    })
 | 
			
		||||
    // if (tableData.value.length === ids.length && page.value > 1) {
 | 
			
		||||
    //   page.value--
 | 
			
		||||
    // }
 | 
			
		||||
    // deleteVisible.value = false
 | 
			
		||||
    closeDialog()
 | 
			
		||||
    getAiList()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
function viewCourseFunc(row) { // 查看课程
 | 
			
		||||
  router.push({ name: 'viewCourse', params: { question_id: row.question_id } })
 | 
			
		||||
}
 | 
			
		||||
function getExercisesName(row) {
 | 
			
		||||
  return JSON.parse(row.question).title
 | 
			
		||||
}
 | 
			
		||||
const std_options_title = ref(['A', 'B', 'C', 'D', 'E', 'F'])
 | 
			
		||||
function addOptionFunc() {
 | 
			
		||||
  // for(let i=0 ;i<std_options_title.value.length;i++) {
 | 
			
		||||
  //     if(!options.value.has(std_options_title.value[i])) {
 | 
			
		||||
  //       options.value.set(std_options_title.value[i],'')
 | 
			
		||||
  //       break;
 | 
			
		||||
  //     }
 | 
			
		||||
  // }
 | 
			
		||||
 | 
			
		||||
  for (let i = 0; i < std_options_title.value.length; i++) {
 | 
			
		||||
    let has_flag = false
 | 
			
		||||
    for (const item of question_form.value.options) {
 | 
			
		||||
      if (item.name === std_options_title.value[i]) {
 | 
			
		||||
        has_flag = true
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if (!has_flag) {
 | 
			
		||||
      const data = {
 | 
			
		||||
        name: std_options_title.value[i],
 | 
			
		||||
        value: ''
 | 
			
		||||
      }
 | 
			
		||||
      question_form.value.options.push(data)
 | 
			
		||||
      break
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
function delet_func(item) {
 | 
			
		||||
  question_form.value.options.pop()
 | 
			
		||||
}
 | 
			
		||||
function handleAvatarSuccess(res) {
 | 
			
		||||
  console.log(res)
 | 
			
		||||
  form.value.cover_img = res.data.file.url
 | 
			
		||||
}
 | 
			
		||||
function beforeAvatarUpload(file) {
 | 
			
		||||
  const isLt05M = file.size / 1024 / 1024 < 20
 | 
			
		||||
  const isJPG = file.type.indexOf('image/') === -1
 | 
			
		||||
  if (isJPG) {
 | 
			
		||||
    ElMessage.error('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件')
 | 
			
		||||
  }
 | 
			
		||||
  if (!isLt05M) {
 | 
			
		||||
    ElMessage.error('上传头像图片大小不能超过 2M!')
 | 
			
		||||
  }
 | 
			
		||||
  return !isJPG && isLt05M
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<template>
 | 
			
		||||
  <div>
 | 
			
		||||
    <!--    搜索框-->
 | 
			
		||||
    <div class="gva-search-box">
 | 
			
		||||
      <el-form ref="searchForm" :inline="true" :model="queryParams">
 | 
			
		||||
        <el-form-item label="AI名称">
 | 
			
		||||
          <el-input v-model="queryParams.name" placeholder="根据AI名称进行查询" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item>
 | 
			
		||||
          <el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button>
 | 
			
		||||
          <el-button size="small" icon="refresh" @click="onReset">重置</el-button>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-form>
 | 
			
		||||
    </div>
 | 
			
		||||
    <!--    表格数据-->
 | 
			
		||||
    <div class="gva-table-box">
 | 
			
		||||
      <!--      批量操作-->
 | 
			
		||||
      <div class="gva-btn-list">
 | 
			
		||||
        <el-button size="small" type="primary" icon="plus" @click="openDialog('add')">新增</el-button>
 | 
			
		||||
        <el-popover v-model="deleteVisible" placement="top" width="160">
 | 
			
		||||
          <p>确定要删除吗?</p>
 | 
			
		||||
          <div style="text-align: right; margin-top: 8px;">
 | 
			
		||||
            <el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button>
 | 
			
		||||
            <el-button size="small" type="primary" @click="onDelete">确定</el-button>
 | 
			
		||||
          </div>
 | 
			
		||||
          <!-- <template #reference>
 | 
			
		||||
            <el-button
 | 
			
		||||
              icon="delete"
 | 
			
		||||
              size="small"
 | 
			
		||||
              type="danger"
 | 
			
		||||
              :disabled="!question_ids.length"
 | 
			
		||||
              style="margin-left: 10px;"
 | 
			
		||||
              @click="deleteVisible = true"
 | 
			
		||||
            >删除</el-button>
 | 
			
		||||
          </template> -->
 | 
			
		||||
        </el-popover>
 | 
			
		||||
      </div>
 | 
			
		||||
      <!--   数据列表-->
 | 
			
		||||
      <el-table :data="tableData" @selection-change="handleSelectionChange">
 | 
			
		||||
        <!-- <el-table-column type="selection" width="55" /> -->
 | 
			
		||||
        <el-table-column align="left" label="ID"  prop="ID" sortable="custom" />
 | 
			
		||||
        <el-table-column align="left" label="内容" min-width="150">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <div>{{ scope.row.content }}</div>
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column align="left" label="关键字" prop="key_word" />
 | 
			
		||||
        <el-table-column align="left" min-width="150" label="其他关键字" prop="linke_title" />
 | 
			
		||||
        <!-- <el-table-column align="left" label="搜索标题" prop="search_title" /> -->
 | 
			
		||||
        <el-table-column align="left" label="创建时间" min-width="150">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            {{ formatDate(scope.row.CreatedAt) }}
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column align="left" fixed="right" label="操作" width="200">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <el-button icon="edit" size="small" type="primary" link @click="editFunc(scope.row)">编辑</el-button>
 | 
			
		||||
            <el-button icon="delete" size="small" type="danger" link @click="deleteFunc(scope.row)">删除</el-button>
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
      </el-table>
 | 
			
		||||
      <div class="gva-pagination">
 | 
			
		||||
        <el-pagination
 | 
			
		||||
          :current-page="queryParams.page"
 | 
			
		||||
          :page-size="queryParams.pageSize"
 | 
			
		||||
          :page-sizes="[10, 30, 50, 100]"
 | 
			
		||||
          :total="total"
 | 
			
		||||
          layout="total, sizes, prev, pager, next, jumper"
 | 
			
		||||
          @current-change="handleCurrentChange"
 | 
			
		||||
          @size-change="handleSizeChange" />
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
    </div>
 | 
			
		||||
    <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="dialogTitle">
 | 
			
		||||
      <el-form ref="apiForm" :model="form" :rules="rules" label-width="80px">
 | 
			
		||||
        <el-form-item label="关键词" prop="key_word">
 | 
			
		||||
          <el-input v-model="form.key_word" placeholder="输入关键词" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="回复内容" prop="content">
 | 
			
		||||
          <!-- <ckEditor v-model="form.content" style="width:100%" :content="form.content" /> -->
 | 
			
		||||
          <el-input
 | 
			
		||||
            v-model="form.content"
 | 
			
		||||
            :rows="2"
 | 
			
		||||
            type="textarea"
 | 
			
		||||
            placeholder="输入回复内容"
 | 
			
		||||
          />
 | 
			
		||||
          <!-- <textarea v-model="form.content" cols="30" rows="10" /> -->
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="其他关键词" prop="linke_title">
 | 
			
		||||
          <el-input v-model.number="form.linke_title" placeholder="输入其他关键词" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-form>
 | 
			
		||||
      <template #footer>
 | 
			
		||||
        <div class="dialog-footer">
 | 
			
		||||
          <el-button size="small" @click="closeDialog">取 消</el-button>
 | 
			
		||||
          <el-button size="small" type="primary" @click="enterDialog">确 定</el-button>
 | 
			
		||||
        </div>
 | 
			
		||||
      </template>
 | 
			
		||||
    </el-dialog>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<style scoped lang="scss">
 | 
			
		||||
.option-item {
 | 
			
		||||
    display: flex;
 | 
			
		||||
    align-items: center;
 | 
			
		||||
    margin-bottom: 10px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.text-ellipsis-1 {
 | 
			
		||||
    /*超出部分省略号 单行*/
 | 
			
		||||
    overflow: hidden;
 | 
			
		||||
    text-overflow: ellipsis;
 | 
			
		||||
    -webkit-line-clamp: 1;
 | 
			
		||||
    display: -webkit-box;
 | 
			
		||||
    -webkit-box-orient: vertical;
 | 
			
		||||
    /* min-height: 38rpx; */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.button-box {
 | 
			
		||||
    padding: 10px 20px;
 | 
			
		||||
 | 
			
		||||
    .el-button {
 | 
			
		||||
        float: right;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.warning {
 | 
			
		||||
    color: #dc143c;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.lbt-thumb {
 | 
			
		||||
    width: 100px;
 | 
			
		||||
    height: 50px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -296,9 +296,10 @@ function beforeAvatarUpload(file) {
 | 
			
		||||
              <div class="show-content text-ellipsis-1" v-html="scope.row.content"></div>
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column align="left" label="封面图" min-width="150">
 | 
			
		||||
        <el-table-column align="left" label="封面图" min-width="50">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
              <img class="lbt-thumb" :src="scope.row.cover_img" alt="">
 | 
			
		||||
              <!-- <img class="lbt-thumb" :src="scope.row.cover_img" alt=""> -->
 | 
			
		||||
              <el-image :src="scope.row.cover_img" fit="cover" />
 | 
			
		||||
            </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column align="left" label="阅读量" prop="reading_num" />
 | 
			
		||||
@@ -413,6 +414,9 @@ function beforeAvatarUpload(file) {
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<style scoped lang="scss">
 | 
			
		||||
:deep(.el-upload--text img) {
 | 
			
		||||
  width: 100px;
 | 
			
		||||
}
 | 
			
		||||
.option-item {
 | 
			
		||||
    display: flex;
 | 
			
		||||
    align-items: center;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										344
									
								
								src/view/bgList/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										344
									
								
								src/view/bgList/index.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,344 @@
 | 
			
		||||
<script setup>
 | 
			
		||||
// 引入依赖
 | 
			
		||||
import api from '@/api/bgList'
 | 
			
		||||
// import { toSQLLine } from '@/utils/stringFun'
 | 
			
		||||
// import WarningBar from '@/components/warningBar/warningBar.vue'
 | 
			
		||||
import { ref, onMounted } from 'vue'
 | 
			
		||||
import { ElMessage, ElMessageBox } from 'element-plus'
 | 
			
		||||
import { useRouter, useRoute } from 'vue-router'
 | 
			
		||||
const router = useRouter()
 | 
			
		||||
const route = useRoute()
 | 
			
		||||
const dialogFormVisible = ref(false)
 | 
			
		||||
import { useUserStore } from '@/pinia/modules/user'
 | 
			
		||||
const userStore = useUserStore()
 | 
			
		||||
import { parseTime } from '@/utils'
 | 
			
		||||
// import { fa } from 'element-plus/es/locale'
 | 
			
		||||
// 变量
 | 
			
		||||
const path = ref(import.meta.env.VITE_BASE_API)
 | 
			
		||||
const queryParams = ref({
 | 
			
		||||
  page: 1,
 | 
			
		||||
  pageSize: 10
 | 
			
		||||
})
 | 
			
		||||
const deleteVisible = ref(false)
 | 
			
		||||
const lbt_ids = ref([])
 | 
			
		||||
const dialogTitle = ref('')
 | 
			
		||||
const form = ref({ status: '1' })
 | 
			
		||||
// const lbtType_options = ref([
 | 
			
		||||
//   {
 | 
			
		||||
//     label: '首页',
 | 
			
		||||
//     value: 1
 | 
			
		||||
//   }
 | 
			
		||||
// ])
 | 
			
		||||
const rules = ref({
 | 
			
		||||
  // lbtName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
 | 
			
		||||
  url: [{ required: true, message: '请选择素材', trigger: 'blur' }],
 | 
			
		||||
  link: [{ required: true, message: '请填写跳转链接', trigger: 'blur' }],
 | 
			
		||||
  // lbtType: [{ required: true, message: '请选择展示位置', trigger: 'blur' }]
 | 
			
		||||
})
 | 
			
		||||
const ruleFormRef = ref(null)
 | 
			
		||||
const tableData = ref([])
 | 
			
		||||
const total = ref(0)
 | 
			
		||||
// 生命周期
 | 
			
		||||
onMounted(() => {
 | 
			
		||||
  getLbtList()
 | 
			
		||||
})
 | 
			
		||||
// 方法
 | 
			
		||||
async function getLbtList() {
 | 
			
		||||
  const res = await api.getBgManageList(queryParams.value)
 | 
			
		||||
  if (res.code === 0) {
 | 
			
		||||
    tableData.value = res.data.list
 | 
			
		||||
    total.value = res.data.total
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
function openDialog(type) {
 | 
			
		||||
  dialogFormVisible.value = true
 | 
			
		||||
  switch (type) {
 | 
			
		||||
    case 'add':
 | 
			
		||||
      dialogTitle.value = '新增背景图'
 | 
			
		||||
      break
 | 
			
		||||
    case 'edit':
 | 
			
		||||
      dialogTitle.value = '编辑背景图'
 | 
			
		||||
      break
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
async function onDelete() {
 | 
			
		||||
  const ids = lbt_ids.value.map(item => item.banner_id)
 | 
			
		||||
  const res = await api.delBg({ ids })
 | 
			
		||||
  if (res.code === 0) {
 | 
			
		||||
    ElMessage({
 | 
			
		||||
      type: 'success',
 | 
			
		||||
      message: res.msg
 | 
			
		||||
    })
 | 
			
		||||
    // if (tableData.value.length === ids.length && page.value > 1) {
 | 
			
		||||
    //   page.value--
 | 
			
		||||
    // }
 | 
			
		||||
    deleteVisible.value = false
 | 
			
		||||
    getLbtList()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
function closeDialog() {
 | 
			
		||||
  dialogFormVisible.value = false
 | 
			
		||||
  form.value = { status: '1' }
 | 
			
		||||
}
 | 
			
		||||
function handleAvatarSuccess(res) {
 | 
			
		||||
  console.log(res)
 | 
			
		||||
  form.value.url = res.data.file.url
 | 
			
		||||
}
 | 
			
		||||
function beforeAvatarUpload(file) {
 | 
			
		||||
  const isLt05M = file.size / 1024 / 1024 < 20
 | 
			
		||||
  const isJPG = file.type.indexOf('image/') === -1
 | 
			
		||||
  if (isJPG) {
 | 
			
		||||
    ElMessage.error('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件')
 | 
			
		||||
  }
 | 
			
		||||
  if (!isLt05M) {
 | 
			
		||||
    ElMessage.error('上传头像图片大小不能超过 2M!')
 | 
			
		||||
  }
 | 
			
		||||
  return !isJPG && isLt05M
 | 
			
		||||
}
 | 
			
		||||
function enterDialog() {
 | 
			
		||||
  console.log(form.value)
 | 
			
		||||
  submitForm(ruleFormRef.value)
 | 
			
		||||
}
 | 
			
		||||
const submitForm = async(formEl) => {
 | 
			
		||||
  if (!formEl) return
 | 
			
		||||
  await formEl.validate((valid, fields) => {
 | 
			
		||||
    if (valid) {
 | 
			
		||||
      console.log('submit!')
 | 
			
		||||
      saveForm()
 | 
			
		||||
    } else {
 | 
			
		||||
      // console.log('error submit!', fields)
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
async function saveForm() {
 | 
			
		||||
//   form.value.status = parseInt(form.value.status)
 | 
			
		||||
//   form.value.linkType = parseInt(form.value.linkType)
 | 
			
		||||
//   form.value.lbtType = parseInt(form.value.lbtType)
 | 
			
		||||
  const params = { // 新参数
 | 
			
		||||
    url: form.value.url,
 | 
			
		||||
    remark: form.value.remark
 | 
			
		||||
    // link: form.value.link
 | 
			
		||||
  }
 | 
			
		||||
  let func_name = ''
 | 
			
		||||
  if (form.value.ID) { // 编辑
 | 
			
		||||
    func_name = 'editBgManage'
 | 
			
		||||
    params.ID = form.value.ID
 | 
			
		||||
  } else {
 | 
			
		||||
    func_name = 'addBgManage'
 | 
			
		||||
  }
 | 
			
		||||
  const res = await api[func_name](params)
 | 
			
		||||
  if (res.code === 0) {
 | 
			
		||||
    ElMessage({
 | 
			
		||||
      type: 'success',
 | 
			
		||||
      message: '操作成功!'
 | 
			
		||||
    })
 | 
			
		||||
    getLbtList()
 | 
			
		||||
    closeDialog()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
const handleSelectionChange = (val) => {
 | 
			
		||||
  lbt_ids.value = val
 | 
			
		||||
}
 | 
			
		||||
function editLbtFunc(item) {
 | 
			
		||||
  console.log(item)
 | 
			
		||||
  form.value = item
 | 
			
		||||
  openDialog('edit')
 | 
			
		||||
}
 | 
			
		||||
function delLbtFunc(item) {
 | 
			
		||||
  ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
 | 
			
		||||
    confirmButtonText: '确定',
 | 
			
		||||
    cancelButtonText: '取消',
 | 
			
		||||
    type: 'warning'
 | 
			
		||||
  })
 | 
			
		||||
    .then(async() => {
 | 
			
		||||
      const res = await api.delBg({
 | 
			
		||||
        // ids: [item.ID]
 | 
			
		||||
        id: item.ID
 | 
			
		||||
      })
 | 
			
		||||
      if (res.code === 0) {
 | 
			
		||||
        ElMessage({
 | 
			
		||||
          type: 'success',
 | 
			
		||||
          message: '删除成功!'
 | 
			
		||||
        })
 | 
			
		||||
        // if (tableData.value.length === 1 && page.value > 1) {
 | 
			
		||||
        //   page.value--
 | 
			
		||||
        // }
 | 
			
		||||
        getLbtList()
 | 
			
		||||
      }
 | 
			
		||||
    }, () => {
 | 
			
		||||
    })
 | 
			
		||||
}
 | 
			
		||||
function handleCurrentChange(val) {
 | 
			
		||||
  queryParams.value.page = val
 | 
			
		||||
  getLbtList()
 | 
			
		||||
}
 | 
			
		||||
function handleSizeChange(val) {
 | 
			
		||||
  queryParams.value.pageSize = val
 | 
			
		||||
  getLbtList()
 | 
			
		||||
}
 | 
			
		||||
const state_loading = ref(false)
 | 
			
		||||
async function changeStateFunc(event, row) { // 改变状态
 | 
			
		||||
  // console.log('changeStateFunc is ====', row, event)
 | 
			
		||||
  // state_loading.value = true
 | 
			
		||||
  // const res = await api.editLbtState({ status: row.status })
 | 
			
		||||
  // state_loading.value = false
 | 
			
		||||
  // // eslint-disable-next-line no-empty
 | 
			
		||||
  // if (res.code === 0) {
 | 
			
		||||
  //   ElMessage({
 | 
			
		||||
  //     type: 'success',
 | 
			
		||||
  //     message: '修改成功!'
 | 
			
		||||
  //   })
 | 
			
		||||
  // return true
 | 
			
		||||
  // } else {
 | 
			
		||||
  //   return false
 | 
			
		||||
  // }
 | 
			
		||||
}
 | 
			
		||||
async function beforeChangeFunc(index, row) {
 | 
			
		||||
  // console.log(row, index)
 | 
			
		||||
  // return false
 | 
			
		||||
  state_loading.value = true
 | 
			
		||||
  const res = await api.editLbtState({ ID: row.ID, status: row.status == 1 ? 2 : 1 })
 | 
			
		||||
  state_loading.value = false
 | 
			
		||||
  // eslint-disable-next-line no-empty
 | 
			
		||||
  if (res.code === 0) {
 | 
			
		||||
    ElMessage({
 | 
			
		||||
      type: 'success',
 | 
			
		||||
      message: '修改成功!'
 | 
			
		||||
    })
 | 
			
		||||
    return true
 | 
			
		||||
  } else {
 | 
			
		||||
    return false
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<template>
 | 
			
		||||
  <div>
 | 
			
		||||
    <div class="gva-table-box">
 | 
			
		||||
      <!--      批量操作-->
 | 
			
		||||
      <div class="gva-btn-list">
 | 
			
		||||
        <el-button size="small" type="primary" icon="plus" @click="openDialog('add')">新增</el-button>
 | 
			
		||||
        <el-popover v-model="deleteVisible" placement="top" width="160">
 | 
			
		||||
          <p>确定要删除吗?</p>
 | 
			
		||||
          <div style="text-align: right; margin-top: 8px;">
 | 
			
		||||
            <el-button size="small" type="primary" link @click="deleteVisible = false">取消</el-button>
 | 
			
		||||
            <el-button size="small" type="primary" @click="onDelete">确定</el-button>
 | 
			
		||||
          </div>
 | 
			
		||||
          <!-- <template #reference>
 | 
			
		||||
            <el-button icon="delete" size="small" type="danger" :disabled="!lbt_ids.length" style="margin-left: 10px;" @click="deleteVisible = true">删除</el-button>
 | 
			
		||||
          </template> -->
 | 
			
		||||
        </el-popover>
 | 
			
		||||
      </div>
 | 
			
		||||
      <!--      数据列表-->
 | 
			
		||||
      <el-table border :data="tableData" @selection-change="handleSelectionChange">
 | 
			
		||||
        <!-- <el-table-column
 | 
			
		||||
          type="selection"
 | 
			
		||||
          width="55"
 | 
			
		||||
        /> -->
 | 
			
		||||
        <!-- <el-table-column align="left" label="名称" min-width="150" prop="lbtName" /> -->
 | 
			
		||||
        <el-table-column align="left" label="缩略图" min-width="150" prop="url">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <img class="lbt-thumb" :src="scope.row.url" alt="">
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <!-- <el-table-column align="left" label="是否启用" min-width="150" prop="status">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <el-switch
 | 
			
		||||
              v-model="scope.row.status"
 | 
			
		||||
              :active-value="1"
 | 
			
		||||
              :loading="state_loading"
 | 
			
		||||
              :inactive-value="2"
 | 
			
		||||
              active-text="启用"
 | 
			
		||||
              inactive-text="禁用"
 | 
			
		||||
              :before-change="() => { return beforeChangeFunc($event, scope.row) }"
 | 
			
		||||
              @change="changeStateFunc($event, scope.row)"
 | 
			
		||||
            />
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column> -->
 | 
			
		||||
        <!-- <el-table-column align="left" label="说明" min-width="150" prop="lbtIntroduction" /> -->
 | 
			
		||||
        <el-table-column align="left" label="更新时间" min-width="150" prop="UpdatedAt">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            {{ parseTime(scope.row.UpdatedAt) }}
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column align="left" label="操作" min-width="150" prop="status">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <el-button
 | 
			
		||||
              icon="edit"
 | 
			
		||||
              size="small"
 | 
			
		||||
              type="primary"
 | 
			
		||||
              link
 | 
			
		||||
              @click="editLbtFunc(scope.row)"
 | 
			
		||||
            >修改</el-button>
 | 
			
		||||
            <el-button
 | 
			
		||||
              icon="delete"
 | 
			
		||||
              size="small"
 | 
			
		||||
              type="danger"
 | 
			
		||||
              link
 | 
			
		||||
              @click="delLbtFunc(scope.row)"
 | 
			
		||||
            >删除</el-button>
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
      </el-table>
 | 
			
		||||
      <div class="gva-pagination">
 | 
			
		||||
        <el-pagination
 | 
			
		||||
          :current-page="queryParams.page"
 | 
			
		||||
          :page-size="queryParams.pageSize"
 | 
			
		||||
          :page-sizes="[10, 30, 50, 100]"
 | 
			
		||||
          :total="total"
 | 
			
		||||
          layout="total, sizes, prev, pager, next, jumper"
 | 
			
		||||
          @current-change="handleCurrentChange"
 | 
			
		||||
          @size-change="handleSizeChange"
 | 
			
		||||
        />
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <!--新增、编辑 窗口-->
 | 
			
		||||
    <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="dialogTitle">
 | 
			
		||||
      <el-form ref="ruleFormRef" :model="form" :rules="rules" label-width="80px">
 | 
			
		||||
        <el-form-item label=" 图片" prop="url">
 | 
			
		||||
          <el-upload
 | 
			
		||||
            class="avatar-uploader"
 | 
			
		||||
            :action="`${path}/fileUploadAndDownload/upload`"
 | 
			
		||||
            :headers="{ 'x-token': userStore.token }"
 | 
			
		||||
            :show-file-list="false"
 | 
			
		||||
            :on-success="handleAvatarSuccess"
 | 
			
		||||
            :before-upload="beforeAvatarUpload"
 | 
			
		||||
          >
 | 
			
		||||
            <img v-if="form.url" :src="form.url" class="img-container">
 | 
			
		||||
            <el-icon v-else class="avatar-uploader-icon">
 | 
			
		||||
              <Plus />
 | 
			
		||||
            </el-icon>
 | 
			
		||||
          </el-upload>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="备注" prop="remark">
 | 
			
		||||
            <el-input v-model="form.remark" placeholder="请输入备注" autocomplete="off" />
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item style="display: none">
 | 
			
		||||
          <el-button type="primary" @click="submitForm(ruleFormRef)">
 | 
			
		||||
            Create
 | 
			
		||||
          </el-button>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
      </el-form>
 | 
			
		||||
      <template #footer>
 | 
			
		||||
        <div class="dialog-footer">
 | 
			
		||||
          <el-button size="small" @click="closeDialog">取 消</el-button>
 | 
			
		||||
          <el-button size="small" type="primary" @click="enterDialog">确 定</el-button>
 | 
			
		||||
        </div>
 | 
			
		||||
      </template>
 | 
			
		||||
    </el-dialog>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<style scoped>
 | 
			
		||||
.img-container {
 | 
			
		||||
    width: 200px;
 | 
			
		||||
    height: 150px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.gva-btn-list {
 | 
			
		||||
    justify-content: end;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.lbt-thumb {
 | 
			
		||||
    width: 100px;
 | 
			
		||||
    height: 50px;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
@@ -9,7 +9,7 @@ import _ from 'lodash'
 | 
			
		||||
// import { toSQLLine } from '@/utils/stringFun'
 | 
			
		||||
// import WarningBar from '@/components/warningBar/warningBar.vue'
 | 
			
		||||
import ckEditor from '@/components/richText/ckEditor5.vue'
 | 
			
		||||
import { ref, onMounted } from 'vue'
 | 
			
		||||
import { ref, onMounted, reactive } from 'vue'
 | 
			
		||||
import { ElMessage, ElMessageBox } from 'element-plus'
 | 
			
		||||
import { useRouter, useRoute } from 'vue-router'
 | 
			
		||||
const router = useRouter()
 | 
			
		||||
@@ -129,8 +129,12 @@ const handleSelectionChange = (val) => {
 | 
			
		||||
}
 | 
			
		||||
function editFunc(row) {
 | 
			
		||||
  form.value = _.cloneDeep(row)
 | 
			
		||||
  console.log(form.value)
 | 
			
		||||
  todo_list.value = form.value.todos
 | 
			
		||||
  // console.log(form.value)
 | 
			
		||||
  // 提醒时间用逗号分隔为数组
 | 
			
		||||
  todo_list.value = _.cloneDeep(form.value.todos)
 | 
			
		||||
  for (const item of todo_list.value) {
 | 
			
		||||
    item.remindTime = item.remindTime.split(',')
 | 
			
		||||
  }
 | 
			
		||||
  note_list.value = form.value.notes
 | 
			
		||||
  openDialog('edit')
 | 
			
		||||
}
 | 
			
		||||
@@ -164,14 +168,10 @@ function handleSizeChange(val) {
 | 
			
		||||
}
 | 
			
		||||
function closeDialog() {
 | 
			
		||||
  dialogFormVisible.value = false
 | 
			
		||||
  // question_form.value = {
 | 
			
		||||
  //   options: [],
 | 
			
		||||
  //   answer: '',
 | 
			
		||||
  //   title: ''
 | 
			
		||||
  // }
 | 
			
		||||
  todo_list.value = []
 | 
			
		||||
  note_list.value = []
 | 
			
		||||
  form.value = {}
 | 
			
		||||
  resetForm()
 | 
			
		||||
}
 | 
			
		||||
async function enterDialog() { // 提交
 | 
			
		||||
  await apiForm.value.validate(async(valid, fields) => {
 | 
			
		||||
@@ -181,8 +181,24 @@ async function enterDialog() { // 提交
 | 
			
		||||
      if (form.value.ID) { // 编辑
 | 
			
		||||
        func_name = 'editHospital'
 | 
			
		||||
      }
 | 
			
		||||
      form.value.todos = todo_list.value
 | 
			
		||||
      form.value.todos = _.cloneDeep(todo_list.value)
 | 
			
		||||
      // 提醒时间用逗号分隔
 | 
			
		||||
      for (const item of form.value.todos) {
 | 
			
		||||
        if (Array.isArray(item.remindTime)) {
 | 
			
		||||
          item.remindTime = item.remindTime.join(',')
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      // 新参数
 | 
			
		||||
      for (const item of note_list.value) {
 | 
			
		||||
        for (let i = 0; i < time_options.value.length; i++) {
 | 
			
		||||
          // eslint-disable-next-line no-empty
 | 
			
		||||
          if (item.notes_time === time_options.value[i]) {
 | 
			
		||||
            item.notes_time_num = i + 1
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      form.value.notes = note_list.value
 | 
			
		||||
      // console.log(form.value);return
 | 
			
		||||
      const res = await api[func_name](form.value)
 | 
			
		||||
      if (res.code === 0) {
 | 
			
		||||
        ElMessage({
 | 
			
		||||
@@ -197,29 +213,92 @@ async function enterDialog() { // 提交
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
function addRowFunc(type) {
 | 
			
		||||
const resetForm = () => {
 | 
			
		||||
  apiForm.value.resetFields()
 | 
			
		||||
}
 | 
			
		||||
function addRowFunc(type, child_index = null) {
 | 
			
		||||
  // {
 | 
			
		||||
  //   content: '',
 | 
			
		||||
  //   notes_time: ''
 | 
			
		||||
  // }
 | 
			
		||||
  if (type === 1) {
 | 
			
		||||
  if (type === 1) { // 注意事项
 | 
			
		||||
    note_list.value.push({
 | 
			
		||||
      content: '',
 | 
			
		||||
      notes_time: ''
 | 
			
		||||
    })
 | 
			
		||||
  } else {
 | 
			
		||||
    todo_list.value.push({
 | 
			
		||||
      content: ''
 | 
			
		||||
    })
 | 
			
		||||
  } else { // 待办事项
 | 
			
		||||
    if (child_index != null) {
 | 
			
		||||
      todo_list.value[child_index].remindTime.push(0)
 | 
			
		||||
    } else {
 | 
			
		||||
      todo_list.value.push({
 | 
			
		||||
        content: '',
 | 
			
		||||
        remindPeriod: 0,
 | 
			
		||||
        frequency: '', // 用药频率
 | 
			
		||||
        remindTime: []
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
function del_ro_func(i, type) {
 | 
			
		||||
function del_ro_func(i, type, child_index = null) {
 | 
			
		||||
  if (type === 1) {
 | 
			
		||||
    note_list.value.splice(i, 1)
 | 
			
		||||
  } else {
 | 
			
		||||
    todo_list.value.splice(i, 1)
 | 
			
		||||
    if (child_index != null) {
 | 
			
		||||
      todo_list.value[i].remindTime.splice(child_index, 1)
 | 
			
		||||
    } else {
 | 
			
		||||
      todo_list.value.splice(i, 1)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
// 图片上传
 | 
			
		||||
const uploading_form = reactive({
 | 
			
		||||
  uploading: false,
 | 
			
		||||
  progressStatus: 'info',
 | 
			
		||||
  percentage: 0, // 进度条
 | 
			
		||||
})
 | 
			
		||||
function init_uploading() {
 | 
			
		||||
  uploading_form.uploading = false
 | 
			
		||||
  uploading_form.progressStatus = 'info'
 | 
			
		||||
  uploading_form.percentage = 0
 | 
			
		||||
}
 | 
			
		||||
function handleAvatarSuccess(res) {
 | 
			
		||||
  console.log('res is ====', res)
 | 
			
		||||
  note_list.value[note_list_item_index.value].content = res.data.file.url
 | 
			
		||||
 | 
			
		||||
  uploading_form.progressStatus = 'info'
 | 
			
		||||
  uploading_form.percentage = 100
 | 
			
		||||
  setTimeout(() => {
 | 
			
		||||
    init_uploading()
 | 
			
		||||
  }, 500)
 | 
			
		||||
}
 | 
			
		||||
function beforeAvatarUpload(file) {
 | 
			
		||||
  init_uploading()
 | 
			
		||||
  uploading_form.uploading = true
 | 
			
		||||
  const isLt05M = file.size / 1024 / 1024 < 20
 | 
			
		||||
  const isJPG = file.type.indexOf('image/') === -1
 | 
			
		||||
  if (isJPG) {
 | 
			
		||||
    uploading_form.uploading = false
 | 
			
		||||
    uploading_form.progressStatus = 'warning'
 | 
			
		||||
    ElMessage.error('文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件')
 | 
			
		||||
  }
 | 
			
		||||
  if (!isLt05M) {
 | 
			
		||||
    uploading_form.uploading = false
 | 
			
		||||
    uploading_form.progressStatus = 'warning'
 | 
			
		||||
    ElMessage.error('上传头像图片大小不能超过 2M!')
 | 
			
		||||
  }
 | 
			
		||||
  const interval = Math.random(100) * 100
 | 
			
		||||
  console.log('interval is ====', interval)
 | 
			
		||||
  setInterval(() => {
 | 
			
		||||
    if (uploading_form.percentage < interval) {
 | 
			
		||||
      uploading_form.percentage += 1
 | 
			
		||||
    }
 | 
			
		||||
  }, 10)
 | 
			
		||||
  return !isJPG && isLt05M
 | 
			
		||||
}
 | 
			
		||||
const note_list_item_index = ref(0)
 | 
			
		||||
function beforeUploadImg(i) {
 | 
			
		||||
  note_list_item_index.value = i
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<template>
 | 
			
		||||
  <div>
 | 
			
		||||
@@ -279,15 +358,15 @@ function del_ro_func(i, type) {
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column align="left" label="医院地址" min-width="150">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <div class="show-content text-ellipsis-1">{{scope.row.addr }}</div>
 | 
			
		||||
            <div class="show-content text-ellipsis-1">{{ scope.row.addr }}</div>
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column align="center" label="注意事项" min-width="150">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <div>{{scope.row.notes.length}}项</div>
 | 
			
		||||
            <div>{{ scope.row.notes.length }}项</div>
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column align="center" label="须知事项" min-width="150">
 | 
			
		||||
        <el-table-column align="center" label="待办事项" min-width="150">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <div>{{ scope.row.todos.length }}项</div>
 | 
			
		||||
          </template>
 | 
			
		||||
@@ -301,20 +380,8 @@ function del_ro_func(i, type) {
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column align="left" fixed="right" label="操作" width="200">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <el-button
 | 
			
		||||
              icon="edit"
 | 
			
		||||
              size="small"
 | 
			
		||||
              type="primary"
 | 
			
		||||
              link
 | 
			
		||||
              @click="editFunc(scope.row)"
 | 
			
		||||
            >编辑</el-button>
 | 
			
		||||
            <el-button
 | 
			
		||||
              icon="delete"
 | 
			
		||||
              size="small"
 | 
			
		||||
              type="danger"
 | 
			
		||||
              link
 | 
			
		||||
              @click="deleteFunc(scope.row)"
 | 
			
		||||
            >删除</el-button>
 | 
			
		||||
            <el-button icon="edit" size="small" type="primary" link @click="editFunc(scope.row)">编辑</el-button>
 | 
			
		||||
            <el-button icon="delete" size="small" type="danger" link @click="deleteFunc(scope.row)">删除</el-button>
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
      </el-table>
 | 
			
		||||
@@ -326,8 +393,7 @@ function del_ro_func(i, type) {
 | 
			
		||||
          :total="total"
 | 
			
		||||
          layout="total, sizes, prev, pager, next, jumper"
 | 
			
		||||
          @current-change="handleCurrentChange"
 | 
			
		||||
          @size-change="handleSizeChange"
 | 
			
		||||
        />
 | 
			
		||||
          @size-change="handleSizeChange" />
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
    </div>
 | 
			
		||||
@@ -346,54 +412,113 @@ function del_ro_func(i, type) {
 | 
			
		||||
          <div class="item-card-box" style="flex:1">
 | 
			
		||||
            <div v-for="(item, i) in note_list" :key="i" class="item-card">
 | 
			
		||||
              <div class="del-row-btn" @click="del_ro_func(i,1)">
 | 
			
		||||
                <el-icon><Close /></el-icon>
 | 
			
		||||
                <el-icon>
 | 
			
		||||
                  <Close />
 | 
			
		||||
                </el-icon>
 | 
			
		||||
              </div>
 | 
			
		||||
              <div class="ic-left">{{ i + 1 }} . </div>
 | 
			
		||||
              <div class="ic-right">
 | 
			
		||||
                <div class="ic-right-row">
 | 
			
		||||
                  <div class="icr-left">注意事项</div>
 | 
			
		||||
                  <div class="icr-right">
 | 
			
		||||
                    <el-input autosize type="textarea" v-model="item.content" />
 | 
			
		||||
                    <!-- <el-input autosize type="textarea" v-model="item.content" /> -->
 | 
			
		||||
                    <el-upload
 | 
			
		||||
                      class="avatar-uploader"
 | 
			
		||||
                      :action="`${path}/fileUploadAndDownload/upload`"
 | 
			
		||||
                      :headers="{ 'x-token': userStore.token }"
 | 
			
		||||
                      :show-file-list="false"
 | 
			
		||||
                      :on-success="handleAvatarSuccess"
 | 
			
		||||
                      :before-upload="beforeAvatarUpload"
 | 
			
		||||
                      @click="beforeUploadImg(i)">
 | 
			
		||||
                      <div v-if="uploading_form.uploading" class="progress-box">
 | 
			
		||||
                        <el-progress
 | 
			
		||||
                          class="progress-item"
 | 
			
		||||
                          :percentage="uploading_form.percentage"
 | 
			
		||||
                          :status="uploading_form.progressStatus" />
 | 
			
		||||
                      </div>
 | 
			
		||||
                      <img v-if="item.content" :src="item.content" class="img-container">
 | 
			
		||||
                      <el-icon v-else class="avatar-uploader-icon">
 | 
			
		||||
                        <Plus />
 | 
			
		||||
                      </el-icon>
 | 
			
		||||
                    </el-upload>
 | 
			
		||||
                  </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="ic-right-row">
 | 
			
		||||
                  <div class="icr-left">注意时间</div>
 | 
			
		||||
                  <div class="icr-right">
 | 
			
		||||
                    <el-select v-model="item.notes_time" class="m-2" placeholder="选择注意时间" size="large">
 | 
			
		||||
                      <el-option
 | 
			
		||||
                        v-for="(item2, i) in time_options"
 | 
			
		||||
                        :key="i"
 | 
			
		||||
                        :label="item2"
 | 
			
		||||
                        :value="item2"
 | 
			
		||||
                      />
 | 
			
		||||
                      <el-option v-for="(item2, i) in time_options" :key="i" :label="item2" :value="item2" />
 | 
			
		||||
                    </el-select>
 | 
			
		||||
                  </div>
 | 
			
		||||
                </div>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="add-row-btn" style="text-align: center;cursor: pointer;" @click="addRowFunc(1)">
 | 
			
		||||
              <el-icon><Plus /></el-icon>
 | 
			
		||||
              <el-icon>
 | 
			
		||||
                <Plus />
 | 
			
		||||
              </el-icon>
 | 
			
		||||
            </div>
 | 
			
		||||
          </div>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
        <el-form-item label="须知事项" prop="notes">
 | 
			
		||||
        <el-form-item label="待办事项" prop="notes">
 | 
			
		||||
          <div class="item-card-box" style="flex:1">
 | 
			
		||||
            <div v-for="(item, i) in todo_list" :key="i" class="item-card">
 | 
			
		||||
              <div class="del-row-btn" @click="del_ro_func(i,2)">
 | 
			
		||||
                <el-icon><Close /></el-icon>
 | 
			
		||||
                <el-icon>
 | 
			
		||||
                  <Close />
 | 
			
		||||
                </el-icon>
 | 
			
		||||
              </div>
 | 
			
		||||
              <div class="ic-left">{{ i + 1 }} . </div>
 | 
			
		||||
              <div class="ic-right">
 | 
			
		||||
                <div class="ic-right-row">
 | 
			
		||||
                  <div class="icr-left">须知事项</div>
 | 
			
		||||
                  <div class="icr-left">待办事项</div>
 | 
			
		||||
                  <div class="icr-right">
 | 
			
		||||
                    <el-input autosize type="textarea" v-model="item.content" />
 | 
			
		||||
                    <el-input v-model="item.content" placeholder="请输入事项内容" autosize type="textarea" />
 | 
			
		||||
                  </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="ic-right-row">
 | 
			
		||||
                  <div class="icr-left">用药频率</div>
 | 
			
		||||
                  <div class="icr-right">
 | 
			
		||||
                    <el-input v-model="item.frequency" placeholder="比如一天3次 一天4次" autosize type="textarea" />
 | 
			
		||||
                  </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="ic-right-row">
 | 
			
		||||
                  <div class="icr-left">待办状态</div>
 | 
			
		||||
                  <div class="icr-right">
 | 
			
		||||
                    <el-select v-model="item.remindPeriod" placeholder="请选择待办状态">
 | 
			
		||||
                      <el-option label="手术前" :value="0" />
 | 
			
		||||
                      <el-option label="手术后" :value="1" />
 | 
			
		||||
                    </el-select>
 | 
			
		||||
                  </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="ic-right-row ic-right-row2">
 | 
			
		||||
                  <div class="icr-left">提醒时间</div>
 | 
			
		||||
                  <div class="icr-right">
 | 
			
		||||
                    <div v-for="(item_l, il) in item.remindTime" :key="il" class="loop_card">
 | 
			
		||||
                      <el-time-picker
 | 
			
		||||
                        v-model="item.remindTime[il]"
 | 
			
		||||
                        value-format="HH:mm"
 | 
			
		||||
                        placeholder="请选择时间"
 | 
			
		||||
                        style="width: 100%;position: relative;" />
 | 
			
		||||
                      <div class="del-row-btn" @click="del_ro_func(i, 2, il)">
 | 
			
		||||
                        <el-icon>
 | 
			
		||||
                          <Close />
 | 
			
		||||
                        </el-icon>
 | 
			
		||||
                      </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div class="add-row-btn" style="text-align: center;cursor: pointer;" @click="addRowFunc(2,i)">
 | 
			
		||||
                      <el-icon>
 | 
			
		||||
                        <Plus />
 | 
			
		||||
                      </el-icon>
 | 
			
		||||
                    </div>
 | 
			
		||||
                  </div>
 | 
			
		||||
                </div>
 | 
			
		||||
              </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="add-row-btn" style="text-align: center;cursor: pointer;" @click="addRowFunc(2)">
 | 
			
		||||
              <el-icon><Plus /></el-icon>
 | 
			
		||||
              <el-icon>
 | 
			
		||||
                <Plus />
 | 
			
		||||
              </el-icon>
 | 
			
		||||
            </div>
 | 
			
		||||
          </div>
 | 
			
		||||
        </el-form-item>
 | 
			
		||||
@@ -408,6 +533,37 @@ function del_ro_func(i, type) {
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
<style scoped lang="scss">
 | 
			
		||||
.loop_card{
 | 
			
		||||
  margin-bottom: 10px;
 | 
			
		||||
  position: relative;
 | 
			
		||||
  .del-row-btn{
 | 
			
		||||
        right: 0;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
.ic-right-row2{
 | 
			
		||||
  align-items: unset !important;
 | 
			
		||||
}
 | 
			
		||||
.progress-box{
 | 
			
		||||
  position: absolute;
 | 
			
		||||
  width: 100%;
 | 
			
		||||
  height: 100%;
 | 
			
		||||
  display: flex;
 | 
			
		||||
  align-items: center;
 | 
			
		||||
  background: #0000001c;
 | 
			
		||||
  justify-content: center;
 | 
			
		||||
  // z-index: 100;
 | 
			
		||||
  .progress-item{
 | 
			
		||||
    width: 90%;
 | 
			
		||||
    :deep(.el-progress__text) {
 | 
			
		||||
      min-width: 10px;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
.img-container {
 | 
			
		||||
    width: 200px;
 | 
			
		||||
    height: 150px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.add-row-btn:hover{
 | 
			
		||||
  background-color: rgb(244, 244, 244);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ const dialogFormVisible = ref(false)
 | 
			
		||||
import { useUserStore } from '@/pinia/modules/user'
 | 
			
		||||
const userStore = useUserStore()
 | 
			
		||||
import { parseTime } from '@/utils'
 | 
			
		||||
import { fa } from 'element-plus/es/locale'
 | 
			
		||||
// import { fa } from 'element-plus/es/locale'
 | 
			
		||||
// 变量
 | 
			
		||||
const path = ref(import.meta.env.VITE_BASE_API)
 | 
			
		||||
const queryParams = ref({
 | 
			
		||||
@@ -23,12 +23,12 @@ const deleteVisible = ref(false)
 | 
			
		||||
const lbt_ids = ref([])
 | 
			
		||||
const dialogTitle = ref('')
 | 
			
		||||
const form = ref({ status: '1' })
 | 
			
		||||
const lbtType_options = ref([
 | 
			
		||||
  {
 | 
			
		||||
    label: '首页',
 | 
			
		||||
    value: 1
 | 
			
		||||
  }
 | 
			
		||||
])
 | 
			
		||||
// const lbtType_options = ref([
 | 
			
		||||
//   {
 | 
			
		||||
//     label: '首页',
 | 
			
		||||
//     value: 1
 | 
			
		||||
//   }
 | 
			
		||||
// ])
 | 
			
		||||
const rules = ref({
 | 
			
		||||
  // lbtName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
 | 
			
		||||
  imgUrl: [{ required: true, message: '请选择素材', trigger: 'blur' }],
 | 
			
		||||
@@ -175,9 +175,27 @@ function handleSizeChange(val) {
 | 
			
		||||
  getLbtList()
 | 
			
		||||
}
 | 
			
		||||
const state_loading = ref(false)
 | 
			
		||||
async function changeStateFunc(row) { // 改变状态
 | 
			
		||||
async function changeStateFunc(event, row) { // 改变状态
 | 
			
		||||
  // console.log('changeStateFunc is ====', row, event)
 | 
			
		||||
  // state_loading.value = true
 | 
			
		||||
  // const res = await api.editLbtState({ status: row.status })
 | 
			
		||||
  // state_loading.value = false
 | 
			
		||||
  // // eslint-disable-next-line no-empty
 | 
			
		||||
  // if (res.code === 0) {
 | 
			
		||||
  //   ElMessage({
 | 
			
		||||
  //     type: 'success',
 | 
			
		||||
  //     message: '修改成功!'
 | 
			
		||||
  //   })
 | 
			
		||||
  // return true
 | 
			
		||||
  // } else {
 | 
			
		||||
  //   return false
 | 
			
		||||
  // }
 | 
			
		||||
}
 | 
			
		||||
async function beforeChangeFunc(index, row) {
 | 
			
		||||
  // console.log(row, index)
 | 
			
		||||
  // return false
 | 
			
		||||
  state_loading.value = true
 | 
			
		||||
  const res = await api.editLbtState({ status: row.status })
 | 
			
		||||
  const res = await api.editLbtState({ ID: row.ID, status: row.status == 1 ? 2 : 1 })
 | 
			
		||||
  state_loading.value = false
 | 
			
		||||
  // eslint-disable-next-line no-empty
 | 
			
		||||
  if (res.code === 0) {
 | 
			
		||||
@@ -222,7 +240,7 @@ async function changeStateFunc(row) { // 改变状态
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
        <el-table-column align="left" label="是否启用" min-width="150" prop="status">
 | 
			
		||||
          <template #default="scope">
 | 
			
		||||
            <el-switch v-model="scope.row.status" :active-value="1" :loadiing="state_loading" :inactive-value="2" active-text="启用" inactive-text="禁用" :before-change="changeStateFunc(scope.row)" />
 | 
			
		||||
            <el-switch v-model="scope.row.status" :active-value="1" :loading="state_loading" :inactive-value="2" active-text="启用" inactive-text="禁用" :before-change="()=>{return beforeChangeFunc($event, scope.row)}" @change="changeStateFunc($event,scope.row)" />
 | 
			
		||||
            <!-- {{ scope.row.status == '1'?'启用':'禁用' }} -->
 | 
			
		||||
          </template>
 | 
			
		||||
        </el-table-column>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user