import qs from 'qs'
import { upcloud_base_common } from "@/config/serviceSettings";
const tablecolumns = {
  //策略表
  grid: {
    items: [
      {
        type: 'input',
        name: 'search',
        label: '查询条件',
        value: ''
      },
      {
        span: 8,
        type: 'buttonGroup',
        style: { textAlign: 'left' },
        options: [
          {
            value: '查询',
            icon: 'search',
            btnType: 'primary',
            style: 'margin-right:10px;margin-left:20px;',
            htmlType: 'submit'
          },
          {
            value: '重置',
            name: 'ccz',
            icon: 'redo',
            on: {
              click(event, form) {
                console.log(form)
                console.log(form.resetFields())
              }
            }
          }
        ]
      }
    ]
  },
  MainTable: {
    ref: 'MainTable',
    rowkey: 'regId',
    detail: [
      {
        title: '参数类型',
        dataIndex: 'groupType',
        key: 'groupType'
      },
      {
        title: '参数编号',
        dataIndex: 'regCode',
        key: 'regCode'
      },

      {
        title: '参数名称',
        dataIndex: 'regName',
        key: 'regName'
      },
      {
        title: '参数值',
        key: 'regValue',
        dataIndex: 'regValue',
        align: 'center'
      },
      {
        title: '货主号',
        key: 'cargoOwnerId',
        dataIndex: 'cargoOwnerId',
        align: 'center'
      },
      {
        title: '仓库号',
        key: 'warehouseId',
        dataIndex: 'warehouseId',
        align: 'center'
      },

      {
        title: '创建人姓名',
        key: 'creatorName',
        dataIndex: 'creatorName',
        align: 'center'
      },
      {
        title: '企业ID',
        key: 'enterpriseId',
        dataIndex: 'enterpriseId',
        align: 'center'
      },
      {
        title: '创建时间',
        key: 'gmtCreate',
        dataIndex: 'gmtCreate',
        align: 'center'
      },
      {
        title: '修改时间',
        key: 'gmtModified',
        dataIndex: 'gmtModified',
        align: 'center'
      },
      {
        title: '修改人姓名',
        key: 'modifierName',
        dataIndex: 'modifierName',
        align: 'center'
      },
      {
        title: '修改等级',
        key: 'modifyLevel',
        dataIndex: 'modifyLevel',
        align: 'center'
      },

      {
        title: '备注',
        key: 'remark',
        dataIndex: 'remark',
        align: 'center'
      }
    ],
    columns: [
      {
        title: '参数类型',
        dataIndex: 'groupType',
        key: 'groupType'
      },
      {
        title: '参数编号',
        dataIndex: 'regCode',
        key: 'regCode'
      },

      {
        title: '参数名称',
        dataIndex: 'regName',
        key: 'regName'
      },
      {
        title: '参数值',
        key: 'regValue',
        dataIndex: 'regValue',
        align: 'center'
      },
      {
        title: '备注',
        key: 'remark',
        dataIndex: 'remark',
        align: 'center'
      },

      {
        title: '操作',
        key: 'operation',
        scopedSlots: { customRender: 'operation' },
        align: 'center'
      }
    ],
    RemoteUrl: {
      url: upcloud_base_common+ '/registry/list',
      method: 'post',
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    },
    remoteBefore(vNode, remoteUrl) {
      //   console.log(vNode, remoteUrl)
      return { ...remoteUrl, data: qs.stringify(remoteUrl.data) }
    },
    doneBefore(res) {
      res.data.list.forEach(item => {
        console.log(item)
        switch (item.modifyLevel) {
          case 10:
            item.modifyLevel = '系统,不可修改'
            break
          case 10:
            item.modifyLevel = '个性化参数,可以修改'
            break
        }
      })

      return res
    }
  }
}

export default tablecolumns
