baizonghao
2023-05-25 3c4d54bcb66d7cec4a35defc999250e200b4fdd2
src/views/common/Publicity.vue
@@ -51,6 +51,7 @@
          <el-table-column label="操作" align="conter">
            <template slot-scope="scope">
              <el-button type="text" size="medium" @click="details(scope.row.id)">详情</el-button>
              <el-button size="medium" type="text" @click="edit(scope.row.id)">修改</el-button>
              <el-button type="text" size="medium" @click="punlish(scope.row.id, scope.row.status)"
                         :disabled="scope.row.status == 2">
                <span v-if="scope.row.status === 1" style="color:#ff0000">下架</span>
@@ -113,35 +114,46 @@
    </el-dialog>
    <!--公共宣传详情弹窗-->
    <el-dialog title="公共宣传详情" :visible.sync="detailsVisible" width="50%" :append-to-body="true"
    <el-dialog :title="title" :visible.sync="detailsVisible" width="50%" :append-to-body="true"
               :before-close="detailsVisibleclose">
      <el-row :gutter="15">
        <el-form ref="addGroupForm" :model="detailsRow" size="medium" label-width="100px">
          <el-col :span="12">
            <el-form-item label="标题" prop="effectiveEtime">
              <el-input v-model="detailsRow.publicityTitle" disabled></el-input>
              <el-input v-model="detailsRow.publicityTitle" :disabled="title=='详情'"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
          <el-form-item label="正文图片">
            <el-upload
                :file-list="detailsRow.media"
                :on-preview="handlePictureCardPreview"
                :on-remove="handleRemoves"
                :on-success="uploadSuccess4"
                :with-credentials="true"
                action="/api/minio/upload"
                list-type="picture-card"
                :with-credentials="true"
                :on-preview="handlePictureCardPreview"
                :on-success="uploadSuccess3"
                :on-remove="handleRemove"
                :file-list="detailsRow.img"
                disabled
                class="freePic">
                :disabled="title=='详情'">
              <i slot="default" class="el-icon-plus"></i>
            </el-upload>
<!--            <el-upload-->
<!--                action="/api/minio/upload"-->
<!--                list-type="picture-card"-->
<!--                :with-credentials="true"-->
<!--                :on-preview="handlePictureCardPreview"-->
<!--                :on-success="uploadSuccess3"-->
<!--                :on-remove="handleRemove"-->
<!--                :file-list="detailsRow.img"-->
<!--                :disabled="title=='详情'"-->
<!--                class="freePic">-->
<!--              <i slot="default" class="el-icon-plus"></i>-->
<!--            </el-upload>-->
          </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="内容 " prop="text">
              <el-input v-model="detailsRow.text" type="textarea" placeholder="请输入公告内容" disabled
              <el-input v-model="detailsRow.text" type="textarea" placeholder="请输入公告内容" :disabled="title=='详情'"
                        :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
            </el-form-item>
          </el-col>
@@ -161,7 +173,7 @@
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="发布时间" prop="effectiveEtime">
              <el-date-picker v-model="detailsRow.releaseTime" type="datetime" placeholder="选择日期时间" disabled
              <el-date-picker v-model="detailsRow.releaseTime" type="datetime" placeholder="选择日期时间" :disabled="title=='详情'"
                              :style="{ width: '100%' }" value-format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
            </el-form-item>
@@ -176,6 +188,12 @@
              <span v-if="detailsRow.status === 1">已发布</span>
              <span v-else-if="detailsRow.status === 0">未发布</span>
              <span v-else="detailsRow.status === 2">已下架</span>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item>
              <el-button type="primary" @click="onSubmit" :disabled="title=='详情'">提交</el-button>
              <el-button @click="detailsVisible= false">取消</el-button>
            </el-form-item>
          </el-col>
        </el-form>
@@ -229,7 +247,7 @@
<script>
import {
  getPublicityList,
  addPublicityList
  addPublicityList, editPublicityList
} from '@/api/publicty'
@@ -237,6 +255,7 @@
  name: "Publicity",
  data() {
    return {
      title:'详情',
      detailsId:null,
      dialogVisibleTime:false,
      fileList: [],
@@ -312,6 +331,18 @@
        handleCloseTime(){
          this.dialogVisibleTime = false
        },
        uploadSuccess4(res, file) {
          console.log(res,this.detailsRow.media.length)
          if (res.code === 200) {
            this.detailsRow.media.push({
              name: res.data,
              url: '/minio/img/' + res.data,
              uid:this.detailsRow.media.length+1
            })
          } else {
            this.$message.error(res.msg)
          }
        },
        uploadSuccess3(res, file) {
          if (res.code === 200) {
            this.addPublicityForm.img.push({
@@ -322,6 +353,11 @@
          } else {
            this.$message.error(res.msg)
          }
        },
        handleRemoves(file, fileList){
          console.log('>>>>>>>>>>>>>>>>>>>>>',this.detailsRow.media)
          this.detailsRow.media = fileList
          console.log(this.detailsRow.media)
        },
        // 正文图片上传,删除操作
        handleRemove(file, fileList) {
@@ -405,20 +441,46 @@
            );
          }
        },
        //详情
        details(val) {
        onSubmit(){
          console.log('提交',this.detailsRow)
          let obj = this.detailsRow
          obj.photoStr = obj.media.map(item=> item.name).join(',')
          editPublicityList(this.detailsRow).then(res=>{
            console.log(res)
              this.detailsVisible = false
            this.$message.success('修改成功')
          })
        },
        edit(val){
          this.title = '修改'
          this.detailsVisible = true;
          this.$http.get('/api/publicity/' + val).then(res => {
            this.detailsRow = res.data.data
            this.detailsRow.img = this.detailsRow['photoStr'].split(',').map(item => {
            this.detailsRow.media = this.detailsRow['photoStr'].split(',').map((item,index) => {
              return {
                name: item,
                url: '/minio/img/' + item,
                uid: this.detailsRow['photoStr'].split(',').length
                uid: index+1
              }
            })
            this.fileList = this.detailsRow.img
            this.fileList = this.detailsRow.media
            console.log(this.detailsRow)
          });
        },
        //详情
        details(val) {
          this.title = '详情'
          this.detailsVisible = true;
          this.$http.get('/api/publicity/' + val).then(res => {
            this.detailsRow = res.data.data
            this.detailsRow.media = this.detailsRow['photoStr'].split(',').map((item,index) => {
              return {
                name: item,
                url: '/minio/img/' + item,
                uid: index+1
              }
            })
            this.fileList = this.detailsRow.media
          });
        },
        //添加