<template>
  <!-- 维护款号成分 -- 发运明细 -->
  <a-modal
    title="维护款号成分"
    v-model="itemNumEleModVis"
    :confirmLoading="confirmLoading"
    width="76%"
    @ok="save"
    @cancel="handleCancel"
  >
    <a-card :bordered="false">
      <div class="table-page-search-wrapper">
        <!-- :rules="validatorRules" -->
        <a-form-model layout="inline" ref="form" :model="editItemNumber">
          <a-row :gutter="24">
            <a-col :md="6" :sm="8">
              <!-- required 必填项 disabled 禁用  -->
              <a-form-model-item label="款号" prop="itemNumber">
                <a-input placeholder="请输入款号" v-model="editItemNumber.itemNumber"></a-input>
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="物料成分" prop="materialComposition">
                <a-input placeholder="请输入物料成分" v-model="editItemNumber.materialComposition"></a-input>
              </a-form-model-item>
            </a-col>

            <a-col :md="6" :sm="8">
              <a-form-model-item label="是否做TC证书" prop="isTc">
                <a-select v-model="editItemNumber.isTc">
                  <a-select-option value="">请选择</a-select-option>
                  <a-select-option value="1">是</a-select-option>
                  <a-select-option value="0">否</a-select-option>
                </a-select>
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
    </a-card>
    <!-- 页面底部保存取消 -->
    <div
      :style="{
        position: 'absolute',
        right: 0,
        bottom: 0,
        width: '100%',
        borderTop: '1px solid #e9e9e9',
        padding: '10px 16px',
        background: '#fff',
        textAlign: 'right',
        zIndex: 1
      }"
    >
      <a-popconfirm title="确定放弃维护款号成分吗？" @confirm="handleCancel" okText="确定" cancelText="取消">
        <a-button :style="{ marginRight: '8px' }">取消</a-button>
      </a-popconfirm>
      <a-button type="primary" @click="save">
        保存
      </a-button>
    </div>
  </a-modal>
</template>

<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JEllipsis from '@/components/jeecg/JEllipsis'

import { addItemNumEle } from '@api/document/shipmentList'

export default {
  name: 'ItemNumEleModal', // 维护款号成分
  mixins: [JeecgListMixin],
  components: { JEllipsis },

  data() {
    return {
      loading: false, // 表格加载
      // orderDataform: this.$form.createForm(this),
      confirmLoading: false,
      itemNumEleModVis: false,
      editItemNumber: {} // 编辑维护款号成分
    }
  },
  // 接收父组件 方法
  // props: {
  //   father: {
  //     type: Function,
  //     default: null
  //   }
  // },
  created() {},
  methods: {
    save() {
      console.log('点击了保存')
      var newObj = {} // 维护款号成分对象
      newObj.itemNumber = this.editItemNumber.itemNumber
      newObj.materialComposition = this.editItemNumber.materialComposition
      newObj.isTc = this.editItemNumber.isTc
      console.log('00')
      if (
        this.editItemNumber.itemNumber === '' ||
        this.editItemNumber.materialComposition === '' ||
        this.editItemNumber.isTc === ''
      ) {
        console.log('11')
        this.$message.error('请输入款号成分')
      } else {
        console.log('22')
        addItemNumEle(newObj).then(res => {
          console.log('newObj', newObj)
          if (res.success) {
            this.$message.success('维护款号成分成功')
            console.log('款号成分对象', newObj)
            console.log('33')
            this.close()
            // 清空信息
            newObj = {}
            newObj.editItemNumber = []
            // this.fatherList() // 调用父组件 查询方法
          }
        })
      }
    },
    // 取消
    cancel() {
      this.itemNumEleModVis = false
      this.close()
    },
    handleCancel() {
      this.close()
    },
    close() {
      this.$emit('close')
      this.itemNumEleModVis = false
    }
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/overwriter.less';
/deep/ .ant-table-thead > tr > th {
  text-align: center;
  // font-weight: 700;
}

/deep/ .ant-table-tbody {
  text-align: center;
}

// /deep/ th.replacecolor {
//   background-color: #ccc;
// }
</style>
