import { orderBaseLogList } from '@/api/workOrderPool.js'
import copyInfo from '../buttons/copyInfo.vue'
import ImageUpload from '@/components/file-upload'
import cloudCall from '../buttons/cloudCall.vue'
export default {
  data() {
    return {
      // 派工信息列表
      logColumns: [
        {
          columnAttributes: {
            label: '操作类别',
            prop: 'type',
            width: 140
          }
        },
        {
          columnAttributes: {
            label: '操作内容',
            prop: 'content',
            'min-width': 200
          }
        },
        {
          columnAttributes: {
            label: '附件',
            prop: 'imgSrc',
            width: 150
          },
          render: (h, { row, column, index }) => {
            return (
              <div style="padding: 0 10px">
                {row.imgSrc
                  ? row.imgSrc.split(',').map(url => (
                      <el-link
                        onClick={() => {
                          window.open(url, '_blank')
                        }}
                        type="primary"
                      >
                        附件{index + 1}
                      </el-link>
                    ))
                  : []}
                {/* <ImageUpload
                  fileList={row.imgSrc ? row.imgSrc.split(',').map(url => ({ url })) : []}
                  limit={100}
                  isEdit={false}
                /> */}
              </div>
            )
          }
        },
        {
          columnAttributes: {
            label: '操作时间',
            prop: 'createTime',
            width: 140
          }
        },
        {
          columnAttributes: {
            label: '操作人',
            prop: 'createBy',
            width: 140
          }
        }
      ],
      logList: []
    }
  },
  computed: {
    // 派工信息
    dispatchInfo() {
      return [
        {
          name: 'el-input',
          md: 24,
          attributes: { disabled: true, placeholder: '请输入' },
          formItemAttributes: { label: '工单单号', prop: 'id' },
          slots: {
            append: (h, { props, onInput }) => {
              return (
                <copyInfo
                  btnys={true}
                  slot="append"
                  text="复制"
                  columnCopyClass="columnCopyClass_cp_888aa"
                  cpText={props?.formData?.id}
                ></copyInfo>
              )
            }
          }
        },
        {
          name: 'slot-component',
          md: 24,
          attributes: { disabled: true, placeholder: '请输入' },
          formItemAttributes: { label: '网点信息', prop: 'websitName' },
          render: (h, { props, onInput }) => {
            var { formData } = props
            return (
              <el-input
                value={`${formData.websitName || ''}-${formData.websitId || ''}`}
                disabled={true}
                size="mini"
                placeholder="请输入"
              ></el-input>
            )
          },
          getValue: () => {
            return `${this.orderInfo.websitName}  ${this.orderInfo.websitId}`
          }
        },
        {
          name: 'el-input',
          md: 12,
          attributes: { disabled: true, placeholder: '请选择' },
          formItemAttributes: { label: '派工状态', prop: 'orderStatusText' }
        },
        {
          name: 'el-input',
          md: 12,
          attributes: { disabled: true, placeholder: '请输入' },
          formItemAttributes: { label: '创建时间', prop: 'createTime' }
        },
        {
          name: 'el-input',
          md: 12,
          attributes: { disabled: true, placeholder: '请输入' },
          formItemAttributes: { label: '派单时间', prop: 'dispatchTime' }
        },
        {
          name: 'el-input',
          md: 12,
          attributes: { disabled: true, placeholder: '请输入' },
          formItemAttributes: { label: '接单时间', prop: 'workerReceTime' }
        },
        ...(() => {
          var list = []
          ;(this.orderInfo.orderWorkers_cp || []).map(item => {
            list.push(
              {
                name: 'slot-component',
                md: 12,
                formItemAttributes: {
                  label: item.isMaster == '1' ? '主要工程师' : item.isMaster == '0' ? '辅助工程师' : '',
                  prop: ''
                },
                render: (h, { props, onInput }) => {
                  return <el-input value={item.workerName} disabled={true} size="mini"></el-input>
                },
                getValue: () => {
                  return item.workerName
                }
              },
              {
                name: 'slot-component',
                md: 12,
                formItemAttributes: { label: '工程师手机号', prop: '' },
                render: (h, { props, onInput }) => {
                  return (
                    <el-input value={item.workerMobile} disabled={true} size="mini">
                      {
                        /* 创建区别：创建的时候不要拨打 */ this.id ? (
                          <cloudCall phone={item.workerMobile} orderInfo={this.orderInfo} slot="append"></cloudCall>
                        ) : null
                      }
                    </el-input>
                  )
                },
                getValue: () => {
                  return item.workerMobile
                }
              }
            )
          })
          return list
        })(),
        {
          isShow: this.formOptions.remark.isShow && !!this.id,
          name: 'el-input',
          md: 24,
          attributes: {
            disabled: !this.formOptions.remark.isEdit,
            type: 'textarea',
            rows: 3,
            placeholder: '请输入'
          },
          formItemAttributes: {
            label: '备注',
            prop: 'remark',
            rules: this.formOptions.remark.isRules
          }
        }
      ]
    }
  },
  methods: {
    // 获取操作记录
    getOrderBaseLogList() {
      if (this.id) {
        orderBaseLogList({
          orderBaseId: this.id
        }).then(res => {
          this.logList = res.data
        })
      }
    }
  }
}
