add.vue 11.5 KB
Newer Older
1 2 3 4 5 6 7
<template>
  <div class="info">
    <div class="info-header">{{ type === 'Update'?'修改':'新建'}}展板版权方</div>
    <div class="info-container">
      <div class="info-wrapper">
          <div class="pageTips">
              <strong>页面说明:</strong>
qzhxx's avatar
qzhxx committed
8
              可新建版权方信息。“*”为必填项。预设展板分类中没有合适的选项,可点击“新建展板分类”在弹框中新建展板分类。
9 10 11 12 13 14
           </div>
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="140px"
qzhxx's avatar
qzhxx committed
15 16 17
          class="demo-form-inline party-form"
          :inline="true"
          label-position="top"
18
        >
qzhxx's avatar
qzhxx committed
19
          <el-form-item label="版权方名称" prop="name" class="w50">
qzhxx's avatar
qzhxx committed
20
            <el-input oninput="value = value.trim()" v-model="ruleForm.name"></el-input>
21 22 23 24 25 26 27 28 29 30 31
          </el-form-item>
          <el-form-item label="版权方有效期" prop="value1">
            <el-date-picker
              value-format="yyyy-MM-dd"
              v-model="ruleForm.value1"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
qzhxx's avatar
qzhxx committed
32
         
qzhxx's avatar
qzhxx committed
33
          <el-form-item class="w50" label="请选择预设展板分类" prop="boardCatIdList">
34
            <el-select
qzhxx's avatar
qzhxx committed
35
              placeholder="请选择预设展板分类"
36 37 38 39 40 41 42 43 44 45 46 47 48
              @focus="getAssetTypeData"
              multiple
              v-model="ruleForm.boardCatIdList"
              @change="getSelectDep"
            >
              <el-checkbox :style="selfstyle" v-model="checkedThing" @change="selectAllThing">全选</el-checkbox>
              <el-option
                v-for="item in videoContentCat"
                :label="item.name"
                :value="item.id"
                :key="item.id"
              ></el-option>
            </el-select>
qzhxx's avatar
qzhxx committed
49
          </el-form-item>
qzhxx's avatar
qzhxx committed
50 51 52
           <el-form-item >
             <br>
            <span style="color:red">若没有相应的展板分类,请点击</span>
qzhxx's avatar
qzhxx committed
53
            <el-button type="text" @click="addBoardClass">新建展板分类</el-button>
54
          </el-form-item>
qzhxx's avatar
qzhxx committed
55
          <el-form-item label="备注" class="w100" prop="remarks">
56 57 58 59 60 61
            <el-input type="textarea" v-model="ruleForm.remarks"></el-input>
          </el-form-item>
        </el-form>
        <!--新增弹框-->
        <el-dialog
          custom-class="party-dialog"
qzhxx's avatar
qzhxx committed
62
          title="新建展板分类"
63 64 65 66 67 68 69 70 71 72
          width="468px"
          :visible.sync="dialogVisible"
          :before-close="close"
        >
          <div class="dialog-content">
            <el-form
              :model="classForm"
              ref="classForm"
              label-width="80px"
              label-position="top"
qzhxx's avatar
qzhxx committed
73
              :rules="rule"
74 75 76
              id="ruleo"
              class="party-form"
            >
qzhxx's avatar
qzhxx committed
77
              <el-form-item label="展板分类名称" prop="name">
qzhxx's avatar
qzhxx committed
78
                <el-input oninput="value = value.trim()" v-model="classForm.name"></el-input>
79
              </el-form-item>
qzhxx's avatar
qzhxx committed
80
              <el-form-item label="备注" prop="remarks">
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
                <el-input type="textarea" v-model="classForm.remarks"></el-input>
              </el-form-item>
            </el-form>
          </div>
          <div slot="footer" class="dialog-footer btn-group">
            <el-button size="mini" type="primary" @click="save('classForm')">确定</el-button>
            <el-button size="mini" @click="close">取 消</el-button>
          </div>
        </el-dialog>
      </div>
    </div>
    <div class="info-footer">
      <div class="btn-group">
        <div class="btn-group">
          <el-button
            type="primary"
            v-show="type === 'add'"
            class="btn_form_search"
            @click="submitForm('ruleForm')"
          >确定</el-button>
          <el-button
            type="primary"
            v-show="type === 'Update'"
            class="btn_form_search"
            @click="updateForm('ruleForm')"
          >确定</el-button>
          <el-button @click="resetForm('ruleForm')">取消</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      type: this.$route.query.type,
      dialogVisible: false,
      classForm: {},
      formLabelWidth: "100px",
      form: {
        name: ""
      },
      value1: [],
      ruleForm: {
qzhxx's avatar
qzhxx committed
127
        value1:[],
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
        boardCatIdList: [],
        name: "",
        ownerType: "EXHIBITION_BOARD"
      },
      videoContentCat: [
        {
          value: "Beijing",
          label: "北京"
        },
        {
          value: "Shanghai",
          label: "上海"
        }
      ],

      checkedThing: false,
      selfstyle: {
        textAlign: "right",
        width: "100%",
        paddingRight: "10px"
      },
qzhxx's avatar
qzhxx committed
149 150 151 152 153
      rule:{
        name: [
          { required: true, message: "请输入展板分类名称", trigger: "blur" },
          { min: 1, max: 20, message: "请输入1到20个字" },
        ],
qzhxx's avatar
qzhxx committed
154 155 156
         remarks:[
          { min: 1, max: 100, message: "请输入1到100个字" },
        ]
qzhxx's avatar
qzhxx committed
157
      },
158 159
      rules: {
        name: [
qzhxx's avatar
qzhxx committed
160 161
          { required: true, message: "请输入版权方名称", trigger: "blur" },
          { min: 1, max: 20, message: "请输入1到20个字" },
162 163
        ],
        boardCatIdList:[
qzhxx's avatar
qzhxx committed
164
          {required: true, message: "请选择展板分类", trigger: "change" }
165 166 167
        ],
        value1:[
          { required: true, message: "请填写版权方有效期", trigger: "change" }
qzhxx's avatar
qzhxx committed
168 169 170
        ],
         remarks:[
          { min: 1, max: 100, message: "请输入1到100个字" },
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
        ]
      }
    };
  },
  watch:{
    // 'ruleForm.value1'(newVal ,oldVal){
    //   // console.log(newVal,oldVal)
    //   this.ruleForm.expireDateEnd = this.ruleForm.value1[1];
    //   this.ruleForm.expireDateStart = this.ruleForm.value1[0];

    // }
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      if (this.$route.query.type === "Update") {
        this.getInfo();
        this.getAssetTypeData()
      }
    },
    //  获取版权方详情
    getInfo() {
      let vm = this;
      vm.$https({
        url: "copyrightOwner/get/" + this.$route.query.id,
        method: "get",
        authType: this.backToken
      })
        .then(res => {
          let data = res.data.data;
          this.ruleForm = data;
qzhxx's avatar
qzhxx committed
204 205 206 207 208 209 210 211 212 213

          let arr = []
          arr = [data.expireDateStart, data.expireDateEnd];
          this.ruleForm.value1 = arr
          this.ruleForm = {...this.ruleForm}

          // this.ruleForm.value1 = [data.expireDateStart, data.expireDateEnd];
          // this.ruleForm.value1[0] = data.expireDateStart + ''
          // this.ruleForm.value1[1] = data.expireDateEnd + ''
          
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
        })
        .catch(function(err) {
          console.log(err);
        });
    },

    // 新建视频分类
    addBoardClass() {
      this.dialogVisible = true;
    },
    // 新建视频分类弹窗保存
    save(formName) {
      this.$refs[formName].validate(valid => {
        this.classForm.expireDateEnd = this.value1[1];
        this.classForm.expireDateStart = this.value1[0];
        if (valid) {
          this.$https(
            {
              url: "exhibitionBoardCat/save",
              method: "post",
              authType: this.backToken
            },
            this.$qs.stringify(this.classForm)
            // this.classForm
          )
            .then(res => {
              console.log(res)
              if(res.data.resultCode === "200"){
                this.$message({ type: "success", message: "新增分类成功!" });
              this.dialogVisible = false;
              }else{
                this.$message({ type: "error", message: res.data.message });
              }
             
            })
            .catch(function(err) {
              this.$message({
                type: "fail",
                message: "新增失败!" + err.response.data.msg
              });
              console.log(err);
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 新增关闭
    close() {
      this.dialogVisible = false;
      for (let key in this.classForm) {
        this.classForm[key] = null;
      }
      this.$refs["classForm"].resetFields();
    },
    // 新增
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
         this.ruleForm.expireDateEnd = this.ruleForm.value1[1];
        this.ruleForm.expireDateStart = this.ruleForm.value1[0];
        if (valid) {
          this.$https(
            {
              url: "copyrightOwner/save",
              method: "post",
              authType: this.backToken
            },
            // this.ruleForm
            this.$qs.stringify(this.ruleForm)
          )
            .then(res => {
              if(res.data.resultCode === "200"){
                this.$message({ type: "success", message: "新增展板版权方成功!" });
                history.go(-1);
              }else{
                this.$message({ type: "error", message: res.data.message });
              }
              
              
            })
            .catch(function(err) {
              console.log(err);
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 修改版权方
    updateForm(formName) {
      this.$refs[formName].validate(valid => {
        this.ruleForm.id = this.$route.query.id;
        this.ruleForm.expireDateEnd = this.ruleForm.value1[1];
        this.ruleForm.expireDateStart = this.ruleForm.value1[0];

        if (valid) {
          this.$https(
            {
              url: "copyrightOwner/update",
              method: "put",
              authType: this.backToken
            },
            this.$qs.stringify(this.ruleForm)
            // this.ruleForm
          )
            .then(res => {
               if(res.data.resultCode === "200"){
                this.$message({ type: "success", message: "修改展板版权方成功!" });
                history.go(-1);
              }else{
                this.$message({ type: "error", message: res.data.message });
              }
            })
            .catch(function(err) {
              console.log(err);
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
      history.go(-1);
    },
    // 获取视频分类列表
    getAssetTypeData() {
      let vm = this;
      vm.$https({
        url: "exhibitionBoardCat/getList",
        method: "post",
        authType: this.backToken
      })
        .then(res => {
          let data = res.data.data;
          this.videoContentCat = data;
          // this.value1[0]=data.expireDateEnd
          //this.value1[1]=data.expireDateStart
        })
        .catch(function(err) {
          console.log(err);
        });
    },
    getSelectDep(boardCatIdList) {
      if (boardCatIdList.length === this.videoContentCat.length) {
        this.checkedThing = true;
      } else {
        this.checkedThing = false;
      }
    },
    selectAllThing() {
      // debugger
      this.ruleForm.boardCatIdList = [];
      if (this.checkedThing) {
        this.videoContentCat.map(item => {
          this.ruleForm.boardCatIdList.push(item.id);
        });
      } else {
        this.ruleForm.boardCatIdList = [];
      }
    }
  }
};
</script>

<style lang="less">
@import "../../../../style/dialog";
</style>