addCopyright.vue 6.22 KB
Newer Older
1 2 3 4
<template>
  <!--新增弹框-->
  <el-dialog
    custom-class="party-dialog"
qzhxx's avatar
qzhxx committed
5
    title="新建视频版权方"
6 7 8
    width="468px"
    :visible.sync="dialogVisible"
    :before-close="close"
qzhxx's avatar
qzhxx committed
9
    
10 11 12 13 14 15 16 17
  >
    <div class="dialog-content">
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="140px"
        class="party-form form-inline"
qzhxx's avatar
qzhxx committed
18
        label-position="top"
19 20 21 22
      >
        <el-form-item label="版权方名称" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
qzhxx's avatar
qzhxx committed
23
        <el-form-item label="版权方有效期" prop="value1">
24 25
          <el-date-picker
            value-format="yyyy-MM-dd"
qzhxx's avatar
qzhxx committed
26
            v-model="ruleForm.value1"
27 28 29 30 31 32
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
qzhxx's avatar
qzhxx committed
33
        <el-form-item class="selectH100" label="请选择预设视频分类" prop="videoContentCatIdList">
34 35 36 37
          <el-select
            placeholder="请选择预设视频分类"
            @focus="getAssetTypeData"
            multiple
qzhxx's avatar
qzhxx committed
38
            v-model="ruleForm.videoContentCatIdList"
39 40 41
            @change="getSelectDep"
          >
            <el-checkbox :style="selfstyle" v-model="checkedThing" @change="selectAllThing">全选</el-checkbox>
qzhxx's avatar
qzhxx committed
42
            <el-option v-for="item in videoContentCat" :label="item.name" :value="item.id" :key="item.id"></el-option>
43 44
          </el-select>
        </el-form-item>
qzhxx's avatar
qzhxx committed
45
        <el-form-item label="备注" class="w100">
46 47 48 49 50
          <el-input type="textarea" v-model="ruleForm.remarks"></el-input>
        </el-form-item>
      </el-form>
    </div>
    <div slot="footer" class="dialog-footer btn-group">
qzhxx's avatar
qzhxx committed
51
      <el-button size="mini" type="primary" @click="submitForm('ruleForm')">确定</el-button>
52 53 54 55 56 57 58 59 60
      <el-button size="mini" @click="close">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
qzhxx's avatar
qzhxx committed
61 62
      value1:[],
      dialogVisible:false,
63
      ruleForm: {
qzhxx's avatar
qzhxx committed
64
        videoContentCatIdList: [],
65
        name: "",
qzhxx's avatar
qzhxx committed
66
        ownerType: "VIDEO_CONTENT"
67
      },
qzhxx's avatar
qzhxx committed
68
      
qzhxx's avatar
qzhxx committed
69
      videoContentCat: [
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
        {
          value: "Beijing",
          label: "北京"
        },
        {
          value: "Shanghai",
          label: "上海"
        }
      ],

      checkedThing: false,
      selfstyle: {
        textAlign: "right",
        width: "100%",
        paddingRight: "10px"
      },
      rules: {
        name: [
qzhxx's avatar
qzhxx committed
88 89
          { required: true, message: "请输入版权方名称", trigger: "blur" },
          { min: 1, max: 20, message: "请输入1到20个字" },
90
        ],
qzhxx's avatar
qzhxx committed
91 92
        videoContentCatIdList:[
          {required: true, message: "请选择视频分类", trigger: "change" }
93
        ],
qzhxx's avatar
qzhxx committed
94 95 96
        value1:[
          { required: true, message: "请填写版权方有效期", trigger: "change" }
        ]
97 98 99 100 101
      }
    };
  },
  methods: {
    // 弹窗保存
qzhxx's avatar
qzhxx committed
102 103 104
    submitForm(formName) {
       this.ruleForm.expireDateEnd = this.ruleForm.value1[1];
        this.ruleForm.expireDateStart = this.ruleForm.value1[0];
105 106 107 108
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.$https(
            {
qzhxx's avatar
qzhxx committed
109 110 111 112 113 114 115 116
              url: "copyrightOwner/save",
              method: "post",
              authType: this.backToken
            },
            // this.ruleForm
            this.$qs.stringify(this.ruleForm)
          )
            .then(res => {
qzhxx's avatar
qzhxx committed
117 118 119
              if(res.data.resultCode === "200"){
                this.$message({ type: "success", message: "新建视频版权方成功!" });
                this.dialogVisible = false
qzhxx's avatar
qzhxx committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
              }else{
                this.$message({ type: "error", message: res.message });
              }
              
              
            })
            .catch(function(err) {
              console.log(err);
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    save(formName) {
      const _this = this
       _this.ruleForm.expireDateEnd = this.ruleForm.value1[1];
        _this.ruleForm.expireDateStart = this.ruleForm.value1[0];
     this.$refs[formName].validate(valid => {
        if (valid) {
          this.$https(
            {
              url: "copyrightOwner/save",
144 145 146
              method: "post",
              authType: this.backToken
            },
qzhxx's avatar
qzhxx committed
147 148
            // this.ruleForm
            _this.$qs.stringify(this.ruleForm)
149 150
          )
            .then(res => {
qzhxx's avatar
qzhxx committed
151 152 153 154 155 156 157
              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 });
              // }
qzhxx's avatar
qzhxx committed
158 159
              
              
160 161 162 163 164 165 166 167 168 169 170 171 172
            })
            .catch(function(err) {
              console.log(err);
            });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    // 新增关闭
    close() {
      this.dialogVisible = false;
qzhxx's avatar
qzhxx committed
173 174
      for (let key in this.ruleForm) {
        this.ruleForm[key] = null;
175
      }
qzhxx's avatar
qzhxx committed
176
      this.$refs["ruleForm"].resetFields();
177 178 179 180 181
    },
     // 获取视频分类列表
    getAssetTypeData() {
      let vm = this;
      vm.$https({
qzhxx's avatar
qzhxx committed
182
        url: "videoContentCat/getList",
183 184 185 186 187
        method: "get",
        authType: this.backToken
      })
        .then(res => {
          let data = res.data.data;
qzhxx's avatar
qzhxx committed
188
          this.videoContentCat = data;
189 190 191 192 193 194 195
          // this.value1[0]=data.expireDateEnd
          //this.value1[1]=data.expireDateStart
        })
        .catch(function(err) {
          console.log(err);
        });
    },
qzhxx's avatar
qzhxx committed
196 197
    getSelectDep(videoContentCatIdList) {
      if (videoContentCatIdList.length === this.videoContentCat.length) {
198 199 200 201 202 203 204
        this.checkedThing = true;
      } else {
        this.checkedThing = false;
      }
    },
    selectAllThing() {
      // debugger
qzhxx's avatar
qzhxx committed
205
      this.ruleForm.videoContentCatIdList = [];
206
      if (this.checkedThing) {
qzhxx's avatar
qzhxx committed
207
        this.videoContentCat.map(item => {
qzhxx's avatar
qzhxx committed
208
          this.ruleForm.videoContentCatIdList.push(item.id);
209 210
        });
      } else {
qzhxx's avatar
qzhxx committed
211
        this.ruleForm.videoContentCatIdList = [];
212 213 214 215 216 217 218 219
      }
    }
  }
};
</script>

<style>
</style>