<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, // 表格加载
      confirmLoading: false,
      itemNumEleModVis: false,
      editItemNumber: {
        itemNumber: '',
        materialComposition: '',
        isTc: ''
      } // 编辑维护款号成分
    }
  },
  // 接收父组件 方法
  props: {
    fatherList: {
      type: Function,
      default: null
    }
  },

  methods: {
    // 保存
    save() {
      addItemNumEle(this.editItemNumber).then(res => {
        if (res.success) {
          this.$message.success('维护款号成分成功')
          this.close()
          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>
