<template>
  <!-- 协议管理 新增、编辑 表单组件 -->
  <div>
    <TableModel
      :columnsList="columnsList"
      :show-btn-crews="false"
      ref="tableRef"
      :show-sel="false"
    >
      <template slot="handle" slot-scope="{ data }">
        <el-button
          type="primary"
          size="mini"
        >查看</el-button
        >
        <el-button
          type="danger"
          size="mini"
        >上传</el-button
        >
      </template>
<!--      <template slot="picUrl" slot-scope="{ data }">
        &lt;!&ndash;              <img :src="data.picUrl" style="width: 50px; height: 50px" alt="">&ndash;&gt;
        <h4
          style="color: #02A7F0; cursor: pointer"
          v-if="data.picUrl === '' || data.picUrl === null"
          @click="handleEditData(data)"
        >上传</h4>
        <h4
          style="color: #02A7F0; cursor: pointer"
          v-else
          @click="openUrl(data.picUrl)"
        >查看</h4>
      </template>
      <template slot="phone" slot-scope="{ data }">
        {{ phoneCrypto(data.phone) }}
      </template>-->
    </TableModel>
  </div>
</template>

<script>
import { columnsList } from '../config-arrival'
import {
  fileUpLoad,
  imgUpLoad
} from '@/api/system/upload'
export default {
  name: 'FormSupplier',
  props: {
    editParams: {
      type: Object,
      default: () => null,
    },
  },
  created() {

  },
  mounted() {
    console.log(this.editParams)
  },
  data() {
    return {
      columnsList,
      subSort: '', // 提交类型：新增 1 / 修改 2
      // 图片集合
      picList: [],
      // 图片名称集合
      picNameList: [],
      //
      fileList: [],
    }
  },
  computed: {
    //图片上传1张后，隐藏上传框
    uploadDisabled() {
      return this.picList.length > 1
    },
  },
  methods: {
    /** 上传图片/文件 */
    uploadData(param) {
      console.log(param)
      imgUpLoad(param).then(res => {
        console.log(res)
        this.picList.push(res.data.url)
        this.picNameList.push(res.data.name.split('_')[0])
      }).catch(err => {})
    },
    /** 移除文件 */
    handleRemove(file) {
      console.log(file)
      console.log(this.picNameList)
      this.picList = []
      // this.fileList = this.fileList.filter(item => item.uid !== e.uid)
    },
    /** 文件超出1个 */
    fileExceed() {
      this.$modal.msgError('最多上传1张图片！')
    },
    /** 确认按钮 */
    onSubmit() {

    },
  },
}
</script>

<style scoped>
::v-deep .el-select {
  width: 100%;
}
::v-deep .el-form-item__label{
  font-weight: normal;
}
</style>
