add.vue 10.6 KB
Newer Older
qzhxx's avatar
qzhxx committed
1
<template>
2 3 4 5 6 7 8 9
  <div class="info">
    <div class="info-header">新建版权方</div>
    <div class="info-container">
      <div class="info-wrapper">
          <div class="pageTips">
              <strong>页面说明:</strong>
              可新建版权方信息。“*”为必填项。预设视频分类中没有合适的选项,可点击“新建视频分类”在弹框中新建分类
           </div>
qzhxx's avatar
qzhxx committed
10
        <el-form
11
          :model="ruleForm"
qzhxx's avatar
qzhxx committed
12
          :rules="rules"
13 14 15
          ref="ruleForm"
          label-width="140px"
          class="party-form form-inline"
qzhxx's avatar
qzhxx committed
16
        >
17 18 19
          <el-form-item label="版权方名称" prop="name">
            <el-input v-model="ruleForm.name"></el-input>
          </el-form-item>
qzhxx's avatar
qzhxx committed
20
          <el-form-item label="版权方有效期" prop="value1">
21 22
            <el-date-picker
              value-format="yyyy-MM-dd"
qzhxx's avatar
qzhxx committed
23
              v-model="ruleForm.value1"
24 25 26 27 28 29 30 31 32 33
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
          <el-form-item class="addTip">
            <span>若没有相应的视频分类,请点击</span>
            <el-button type="text" @click="addVideoClass">新建视频分类</el-button>
          </el-form-item>
qzhxx's avatar
qzhxx committed
34
          <el-form-item class="selectH100" label="请选择视频分类" prop="videoContentCatIdList">
35 36 37 38
            <el-select
              placeholder="请选择预设视频分类"
              @focus="getAssetTypeData"
              multiple
qzhxx's avatar
qzhxx committed
39
              v-model="ruleForm.videoContentCatIdList"
40 41 42 43
              @change="getSelectDep"
            >
              <el-checkbox :style="selfstyle" v-model="checkedThing" @change="selectAllThing">全选</el-checkbox>
              <el-option
qzhxx's avatar
qzhxx committed
44
                v-for="item in videoContentCat"
45 46 47 48 49
                :label="item.name"
                :value="item.id"
                :key="item.id"
              ></el-option>
            </el-select>
qzhxx's avatar
qzhxx committed
50 51
          </el-form-item>
          <el-form-item label="备注">
52
            <el-input type="textarea" v-model="ruleForm.remarks"></el-input>
qzhxx's avatar
qzhxx committed
53 54
          </el-form-item>
        </el-form>
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
        <!--新增弹框-->
        <el-dialog
          custom-class="party-dialog"
          title="新建视频分类"
          width="468px"
          :visible.sync="dialogVisible"
          :before-close="close"
        >
          <div class="dialog-content">
            <el-form
              :model="classForm"
              ref="classForm"
              label-width="80px"
              label-position="top"
              :rules="rules"
              id="ruleo"
              class="party-form"
            >
              <el-form-item label="视频分类名称" prop="name">
                <el-input v-model="classForm.name"></el-input>
              </el-form-item>
              <el-form-item label="备注">
                <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>
qzhxx's avatar
qzhxx committed
86
      </div>
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    </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>
qzhxx's avatar
qzhxx committed
105
      </div>
106
    </div>
qzhxx's avatar
qzhxx committed
107 108
  </div>
</template>
109

qzhxx's avatar
qzhxx committed
110 111 112 113
<script>
export default {
  data() {
    return {
114
      type: this.$route.query.type,
qzhxx's avatar
qzhxx committed
115
      dialogVisible: false,
qzhxx's avatar
qzhxx committed
116
      classForm: {},
qzhxx's avatar
qzhxx committed
117 118 119 120
      formLabelWidth: "100px",
      form: {
        name: ""
      },
121
      value1: [],
qzhxx's avatar
qzhxx committed
122
      ruleForm: {
qzhxx's avatar
qzhxx committed
123
        videoContentCatIdList: [],
qzhxx's avatar
qzhxx committed
124
        name: "",
qzhxx's avatar
qzhxx committed
125
        ownerType: "VIDEO_CONTENT"
qzhxx's avatar
qzhxx committed
126
      },
qzhxx's avatar
qzhxx committed
127
      videoContentCat: [
qzhxx's avatar
qzhxx committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
        {
          value: "Beijing",
          label: "北京"
        },
        {
          value: "Shanghai",
          label: "上海"
        }
      ],

      checkedThing: false,
      selfstyle: {
        textAlign: "right",
        width: "100%",
        paddingRight: "10px"
      },
      rules: {
        name: [
146
          { required: true, message: "请输入版权方名称", trigger: "blur" }
147
          // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
qzhxx's avatar
qzhxx committed
148
        ],
qzhxx's avatar
qzhxx committed
149 150
        videoContentCatIdList:[
          {required: true, message: "请选择视频分类", trigger: "change" }
qzhxx's avatar
qzhxx committed
151
        ],
qzhxx's avatar
qzhxx committed
152 153 154
        value1:[
          { required: true, message: "请填写版权方有效期", trigger: "change" }
        ]
qzhxx's avatar
qzhxx committed
155 156 157
      }
    };
  },
qzhxx's avatar
qzhxx committed
158 159 160 161 162 163 164 165
  watch:{
    // 'ruleForm.value1'(newVal ,oldVal){
    //   // console.log(newVal,oldVal)
    //   this.ruleForm.expireDateEnd = this.ruleForm.value1[1];
    //   this.ruleForm.expireDateStart = this.ruleForm.value1[0];

    // }
  },
166 167
  mounted() {
    this.init();
168
  },
qzhxx's avatar
qzhxx committed
169
  methods: {
170 171 172 173
    init() {
      if (this.$route.query.type === "Update") {
        this.getInfo();
        this.getAssetTypeData()
174 175 176
      }
    },
    //  获取版权方详情
177
    getInfo() {
178
      let vm = this;
179 180 181 182 183
      vm.$https({
        url: "copyrightOwner/get/" + this.$route.query.id,
        method: "get",
        authType: this.backToken
      })
184
        .then(res => {
qzhxx's avatar
qzhxx committed
185
          let data = res.data.data;
186
          this.ruleForm = data;
qzhxx's avatar
qzhxx committed
187
          this.ruleForm.value1 = [data.expireDateStart, data.expireDateEnd];
188 189 190 191 192
        })
        .catch(function(err) {
          console.log(err);
        });
    },
193

qzhxx's avatar
qzhxx committed
194 195 196 197
    // 新建视频分类
    addVideoClass() {
      this.dialogVisible = true;
    },
qzhxx's avatar
qzhxx committed
198
    // 新建视频分类弹窗保存
199
    save(formName) {
200
      this.$refs[formName].validate(valid => {
qzhxx's avatar
qzhxx committed
201 202
        this.classForm.expireDateEnd = this.value1[1];
        this.classForm.expireDateStart = this.value1[0];
203
        if (valid) {
204
          this.$https(
205
            {
qzhxx's avatar
qzhxx committed
206
              url: "videoContentCat/save",
207 208 209
              method: "post",
              authType: this.backToken
            },
qzhxx's avatar
qzhxx committed
210
            this.$qs.stringify(this.classForm)
qzhxx's avatar
qzhxx committed
211
            // this.classForm
212
          )
213
            .then(res => {
qzhxx's avatar
qzhxx committed
214 215 216
              console.log(res)
              if(res.data.resultCode === "200"){
                this.$message({ type: "success", message: "新增分类成功!" });
217
              this.dialogVisible = false;
qzhxx's avatar
qzhxx committed
218 219 220 221
              }else{
                this.$message({ type: "error", message: res.data.message });
              }
             
222 223
            })
            .catch(function(err) {
224 225 226 227
              this.$message({
                type: "fail",
                message: "新增失败!" + err.response.data.msg
              });
228 229 230 231 232 233 234
              console.log(err);
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
qzhxx's avatar
qzhxx committed
235 236 237 238 239 240 241 242 243
    },
    // 新增关闭
    close() {
      this.dialogVisible = false;
      for (let key in this.classForm) {
        this.classForm[key] = null;
      }
      this.$refs["classForm"].resetFields();
    },
244
    // 新增
qzhxx's avatar
qzhxx committed
245 246
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
qzhxx's avatar
qzhxx committed
247 248
         this.ruleForm.expireDateEnd = this.ruleForm.value1[1];
        this.ruleForm.expireDateStart = this.ruleForm.value1[0];
249
        if (valid) {
250
          this.$https(
251 252 253 254 255 256 257
            {
              url: "copyrightOwner/save",
              method: "post",
              authType: this.backToken
            },
            // this.ruleForm
            this.$qs.stringify(this.ruleForm)
258
          )
259
            .then(res => {
qzhxx's avatar
qzhxx committed
260
              if(res.data.resultCode === "200"){
qzhxx's avatar
qzhxx committed
261
                this.$message({ type: "success", message: "新增视频版权成功!" });
qzhxx's avatar
qzhxx committed
262 263
                history.go(-1);
              }else{
qzhxx's avatar
qzhxx committed
264
                this.$message({ type: "error", message: res.data.message });
qzhxx's avatar
qzhxx committed
265 266 267
              }
              
              
268 269 270 271 272 273 274 275 276 277 278 279 280
            })
            .catch(function(err) {
              console.log(err);
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 修改版权方
    updateForm(formName) {
      this.$refs[formName].validate(valid => {
281
        this.ruleForm.id = this.$route.query.id;
qzhxx's avatar
qzhxx committed
282 283
        this.ruleForm.expireDateEnd = this.ruleForm.value1[1];
        this.ruleForm.expireDateStart = this.ruleForm.value1[0];
284

qzhxx's avatar
qzhxx committed
285
        if (valid) {
286
          this.$https(
287 288 289 290 291 292 293
            {
              url: "copyrightOwner/update",
              method: "put",
              authType: this.backToken
            },
            this.$qs.stringify(this.ruleForm)
            // this.ruleForm
294
          )
295
            .then(res => {
qzhxx's avatar
qzhxx committed
296
               if(res.data.resultCode === "200"){
qzhxx's avatar
qzhxx committed
297
                this.$message({ type: "success", message: "修改视频版权方成功!" });
qzhxx's avatar
qzhxx committed
298 299 300 301
                history.go(-1);
              }else{
                this.$message({ type: "error", message: res.data.message });
              }
302 303 304 305
            })
            .catch(function(err) {
              console.log(err);
            });
qzhxx's avatar
qzhxx committed
306 307 308 309 310 311 312 313 314 315
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
      history.go(-1);
    },
316 317 318 319
    // 获取视频分类列表
    getAssetTypeData() {
      let vm = this;
      vm.$https({
qzhxx's avatar
qzhxx committed
320
        url: "videoContentCat/getList",
321 322 323 324 325
        method: "get",
        authType: this.backToken
      })
        .then(res => {
          let data = res.data.data;
qzhxx's avatar
qzhxx committed
326
          this.videoContentCat = data;
327 328 329 330 331 332 333
          // this.value1[0]=data.expireDateEnd
          //this.value1[1]=data.expireDateStart
        })
        .catch(function(err) {
          console.log(err);
        });
    },
qzhxx's avatar
qzhxx committed
334 335
    getSelectDep(videoContentCatIdList) {
      if (videoContentCatIdList.length === this.videoContentCat.length) {
qzhxx's avatar
qzhxx committed
336 337 338 339 340 341 342
        this.checkedThing = true;
      } else {
        this.checkedThing = false;
      }
    },
    selectAllThing() {
      // debugger
qzhxx's avatar
qzhxx committed
343
      this.ruleForm.videoContentCatIdList = [];
qzhxx's avatar
qzhxx committed
344
      if (this.checkedThing) {
qzhxx's avatar
qzhxx committed
345
        this.videoContentCat.map(item => {
qzhxx's avatar
qzhxx committed
346
          this.ruleForm.videoContentCatIdList.push(item.id);
qzhxx's avatar
qzhxx committed
347 348
        });
      } else {
qzhxx's avatar
qzhxx committed
349
        this.ruleForm.videoContentCatIdList = [];
qzhxx's avatar
qzhxx committed
350 351 352 353 354
      }
    }
  }
};
</script>
355

qzhxx's avatar
qzhxx committed
356
<style lang="less">
qzhxx's avatar
qzhxx committed
357
@import "../../../../style/dialog";
qzhxx's avatar
qzhxx committed
358
</style>