addCopyright.vue 5.54 KB
Newer Older
1 2 3 4 5 6 7 8
<template>
  <!--新增弹框-->
  <el-dialog
    custom-class="party-dialog"
    title="新建视频分类"
    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 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
      >
        <el-form-item label="版权方名称" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="版权方有效期" required>
          <el-date-picker
            value-format="yyyy-MM-dd"
            v-model="value1"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
        <el-form-item class="selectH100" label="请选择预设视频分类">
          <el-select
            placeholder="请选择预设视频分类"
            @focus="getAssetTypeData"
            multiple
            v-model="ruleForm.assetTypeIdList"
            @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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
          </el-select>
        </el-form-item>
        <el-form-item label="备注">
          <el-input type="textarea" v-model="ruleForm.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>
</template>

<script>
export default {
  data() {
    return {
qzhxx's avatar
qzhxx committed
61
      dialogVisible:true,
62 63 64
      ruleForm: {
        assetTypeIdList: [],
        name: "",
qzhxx's avatar
qzhxx committed
65
        ownerType: "VIDEO_CONTENT"
66 67 68 69
      },
            ruleForm: {
        assetTypeIdList: [],
        name: "",
qzhxx's avatar
qzhxx committed
70
        ownerType: "VIDEO_CONTENT"
71
      },
qzhxx's avatar
qzhxx committed
72
      videoContentCat: [
73 74 75 76 77 78 79 80 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 127 128 129 130 131 132 133
        {
          value: "Beijing",
          label: "北京"
        },
        {
          value: "Shanghai",
          label: "上海"
        }
      ],

      checkedThing: false,
      selfstyle: {
        textAlign: "right",
        width: "100%",
        paddingRight: "10px"
      },
      rules: {
        name: [
          { required: true, message: "请输入版权方名称", trigger: "blur" }
          // { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
        ],
        date1: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change"
          }
        ],
        date2: [
          {
            type: "date",
            required: true,
            message: "请选择时间",
            trigger: "change"
          }
        ],
        type: [
          {
            type: "array",
            required: true,
            message: "请至少选择一个活动性质",
            trigger: "change"
          }
        ],
        resource: [
          { required: true, message: "请选择活动资源", trigger: "change" }
        ],
        desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }]
      }
    };
  },
  methods: {
    // 弹窗保存
    save(formName) {
      this.$refs[formName].validate(valid => {
        this.ruleForm.expireDateEnd = this.value1[1];
        this.ruleForm.expireDateStart = this.value1[0];
        if (valid) {
          this.$https(
            {
qzhxx's avatar
qzhxx committed
134
              url: "videoContentCat/save",
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
              method: "post",
              authType: this.backToken
            },
            this.classForm
          )
            .then(res => {
              this.$message({ type: "success", message: "新增分类成功!" });
              this.dialogVisible = false;
            })
            .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();
    },
     // 获取视频分类列表
    getAssetTypeData() {
      let vm = this;
      vm.$https({
qzhxx's avatar
qzhxx committed
169
        url: "videoContentCat/getList",
170 171 172 173 174
        method: "get",
        authType: this.backToken
      })
        .then(res => {
          let data = res.data.data;
qzhxx's avatar
qzhxx committed
175
          this.videoContentCat = data;
176 177 178 179 180 181 182 183
          // this.value1[0]=data.expireDateEnd
          //this.value1[1]=data.expireDateStart
        })
        .catch(function(err) {
          console.log(err);
        });
    },
    getSelectDep(assetTypeIdList) {
qzhxx's avatar
qzhxx committed
184
      if (assetTypeIdList.length === this.videoContentCat.length) {
185 186 187 188 189 190 191 192 193
        this.checkedThing = true;
      } else {
        this.checkedThing = false;
      }
    },
    selectAllThing() {
      // debugger
      this.ruleForm.assetTypeIdList = [];
      if (this.checkedThing) {
qzhxx's avatar
qzhxx committed
194
        this.videoContentCat.map(item => {
195 196 197 198 199 200 201 202 203 204 205 206
          this.ruleForm.assetTypeIdList.push(item.id);
        });
      } else {
        this.ruleForm.assetTypeIdList = [];
      }
    }
  }
};
</script>

<style>
</style>