<template>
  <div class="container">
    <el-row>
      <el-col :span="12">
        <h2 class="bg-left">修改合同信息</h2>
      </el-col>
      <el-col :span="12" class="bg-right">
        <el-button
          class="bg-bottom"
          type="primary"
          size="small"
          @click="returnsales()"
          >返回</el-button
        >
      </el-col>
    </el-row>

    <div class="wenzi">
      <h3>基本信息</h3>
      <p>
        &nbsp;&nbsp;注：基本信息和货物信息均为必填项，“*”
        标记的条目提交后不可修改。
      </p>
    </div>
    <div class="center">
      <ws-form
        ref="deptBudgetList"
        :rules="ruleDeptBudget"
        :model="deptBudgetList"
      >
        <!--基本信息-->
        <ws-info-table>
          <!--合同编号-->
          <ws-form-item label="合同编号" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.contractNo"
              maxlength="100"
              size="small"
            />
            <span class="unchangeable">*</span>
          </ws-form-item>

          <!--运输方式-->
          <ws-form-item label="运输方式" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.shippingType"
              maxlength="100"
              size="small"
            />
          </ws-form-item>

          <!--买方-->
          <ws-form-item label="买方" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.buyer"
              maxlength="100"
              size="small"
            />
            <span class="unchangeable">*</span>
          </ws-form-item>

          <!--结算方式-->
          <ws-form-item label="结算方式" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.settlementMethod"
              maxlength="100"
              size="small"
            />
          </ws-form-item>

          <!--卖方-->
          <ws-form-item label="卖方" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.seller"
              maxlength="100"
              size="small"
            />
            <span class="unchangeable">*</span>
          </ws-form-item>

          <!--货源地-->
          <ws-form-item label="货源地" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.sourceGoods"
              maxlength="100"
              size="small"
            />
          </ws-form-item>
          <!--买方电话-->
          <ws-form-item label="买方电话" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.buyerPhone"
              maxlength="100"
              size="small"
            />
          </ws-form-item>

          <!--交货地-->
          <ws-form-item label="交货地" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.placeDelivery"
              maxlength="100"
              size="small"
            />
          </ws-form-item>

          <!--卖方电话-->
          <ws-form-item label="卖方电话" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.sellerPhone"
              maxlength="100"
              size="small"
            />
          </ws-form-item>

          <!--包装方式-->
          <ws-form-item label="包装方式" span="1" prop="packingMethod">
            <ws-select
              v-model="deptBudgetList.packingMethod"
              placeholder=""
              class="typeselect"
              @change="selectpackingMethod"
            >
              <ws-option
                v-for="item in packtypeList"
                :key="item.constKey"
                :label="item.constValue"
                :value="item.constValue"
              />
            </ws-select>
          </ws-form-item>
          <!--重量（吨）-->
          <ws-form-item label="重量（吨）" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.weight"
              maxlength="100"
              size="small"
            />
          </ws-form-item>

          <!--验收方式-->
          <ws-form-item label="验收方式" span="1" prop="acceptanceMethod">
            <el-select
              v-model="deptBudgetList.acceptanceMethod"
              placeholder="请选择验收方式"
              style="width: 100%"
              filterable
              @change="selectunitList"
            >
              <el-option
                v-for="(item, index) in unitList"
                :key="item.constValue"
                :label="item.constValue"
                :value="item.constValue"
              >
                <span class="unit-left" style="float: left">
                  <span v-if="item.flag == 'delete'">
                    {{ item.constValue }}</span
                  >
                  <!-- 新增文本框 -->
                  <div
                    style="width: 160px"
                    v-if="item.flag !== 'delete'"
                    @click.stop
                  >
                    <ws-input
                      v-model="item.constValue"
                      clearable
                      maxlength="10"
                      style="width: 100%"
                    ></ws-input>
                  </div>
                </span>
                <span style="float: right; color: #8492a6; font-size: 13px">
                  <!-- 对号 -->
                  <i
                    class="el-icon-check"
                    style="line-height: 29px; margin-left: 10px"
                    v-if="item.flag !== 'delete'"
                    @click.stop="saveClick(item, index)"
                  ></i>
                  <!-- 编辑 -->
                  <i
                    class="el-icon-edit"
                    style="line-height: 29px; margin-left: 10px"
                    v-if="item.flag == 'delete'"
                    @click.stop="editClick(item, index)"
                  ></i>
                  <!-- 删除 -->
                  <i
                    class="el-icon-delete"
                    style="line-height: 29px"
                    @click.stop="deleteClick(item, index)"
                  ></i>
                </span>
              </el-option>
              <!-- 新增按钮 -->
              <el-option value="" label="">
                <div style="text-align: center">
                  <ws-button type="primary" @click.stop="addClick">{{
                    $t('button.add')
                  }}</ws-button>
                </div>
              </el-option>
            </el-select>
          </ws-form-item>

          <!--溢短装（%）-->
          <ws-form-item label="溢短装（%））" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.overShort"
              maxlength="100"
              size="small"
            />
          </ws-form-item>
          <!--交货日期（起）-->
          <ws-form-item
            label="交货日期（起）"
            span="1"
            prop="deliveryDateStart"
          >
            <ws-date-picker
              :picker-options="pickerBeginDateBefore"
              v-model="deptBudgetList.deliveryDateStart"
              type="date"
              default-value="1980-01-01"
              placeholder="起始日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </ws-form-item>

          <!--合同单价（元/吨）-->
          <ws-form-item label="合同单价（元/吨）" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.unitContractPrice"
              maxlength="100"
              size="small"
            />
            <span class="unchangeable">*</span>
          </ws-form-item>

          <!--交货日期（止）-->
          <ws-form-item label="交货日期（止）" span="1" prop="deliveryDateEnd">
            <ws-date-picker
              :picker-options="pickerBeginDateBefore"
              v-model="deptBudgetList.deliveryDateEnd"
              type="date"
              default-value="1980-01-01"
              placeholder="起始日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </ws-form-item>

          <!--合同总价-->
          <ws-form-item label="合同总价" span="1" prop="contractNo">
            <ws-input
              v-model="deptBudgetList.totalContractPrice"
              maxlength="100"
              size="small"
            />
          </ws-form-item>
          <!--签订日期-->
          <ws-form-item label="签订日期" span="1" prop="signingDate">
            <ws-date-picker
              :picker-options="pickerBeginDateBefore"
              v-model="deptBudgetList.signingDate"
              type="date"
              default-value="1980-01-01"
              placeholder="起始日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </ws-form-item>
        </ws-info-table>
      </ws-form>
      <!-- <base-card> -->
      <div class="wenzi">
        <h3>货物信息</h3>
      </div>
      <div class="center">
        <ws-form
          ref="deptBudgetList"
          :rules="ruleDeptBudget"
          :model="deptBudgetList"
        >
          <!--货物信息-->
          <ws-info-table>
            <!--货名-->
            <ws-form-item label="货名" span="1" prop="goodsName">
              <ws-select
                v-model="deptBudgetList.contractGoodsInfo.goodsName"
                placeholder=""
                class="typeselect"
                @change="selectpackingMethod"
              >
                <ws-option
                  v-for="item in goodnameList"
                  :key="item.constKey"
                  :label="item.constValue"
                  :value="item.constValue"
                />
              </ws-select>
              <span class="unchangeable">*</span>
            </ws-form-item>

            <!--水分（%）<=-->
            <ws-form-item label="水分（%）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractGoodsInfo.waterContent"
                maxlength="100"
                size="small"
              />
            </ws-form-item>

            <!--品级-->
            <ws-form-item label="品级" span="1" prop="grade">
              <ws-select
                v-model="deptBudgetList.contractGoodsInfo.grade"
                placeholder=""
                class="typeselect"
                @change="selectgrade"
              >
                <ws-option
                  v-for="item in gradeList"
                  :key="item.constKey"
                  :label="item.constValue"
                  :value="item.constValue"
                />
              </ws-select>
            </ws-form-item>

            <!--杂质（%）<=-->
            <ws-form-item label="杂质（%）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractGoodsInfo.impurity"
                maxlength="100"
                size="small"
              />
            </ws-form-item>

            <!--容量（克/升）>=-->
            <ws-form-item label="容量（克/升）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractGoodsInfo.bulkDensity"
                maxlength="100"
                size="small"
              />
            </ws-form-item>

            <!--霉变粒（%）<=-->
            <ws-form-item label="霉变粒（%）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractGoodsInfo.mildewGrain"
                maxlength="100"
                size="small"
              />
            </ws-form-item>

            <!--热损伤（%）<=-->
            <ws-form-item label="热损伤（%）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractGoodsInfo.jiaorenli"
                maxlength="100"
                size="small"
              />
            </ws-form-item>
            <!--不完整粒（%）<=-->
            <ws-form-item label="不完整粒（%）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractGoodsInfo.imperfectGrain"
                maxlength="100"
                size="small"
              />
            </ws-form-item>
          </ws-info-table>
        </ws-form>
      </div>
      <div class="wenzi">
        <h3>流程信息</h3>
      </div>
      <div class="center">
        <ws-form
          ref="deptBudgetList"
          :rules="ruleDeptBudget"
          :model="deptBudgetList"
        >
          <!--流程信息-->

          <ws-info-table>
            <!--合同收入（元）-->
            <ws-form-item label="合同收入（元）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractProcessInfo.goodsNameKey"
                maxlength="100"
                size="small"
              />
            </ws-form-item>

            <!--已开发票（元）-->
            <ws-form-item label="已开发票（元）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractProcessInfo.goodsName"
                maxlength="100"
                size="small"
              />
            </ws-form-item>

            <!--费用支出（元）-->
            <ws-form-item label="费用支出（元）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractProcessInfo.waterContent"
                maxlength="100"
                size="small"
              />
            </ws-form-item>

            <!--未开发票（元）-->
            <ws-form-item label="未开发票（元）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractProcessInfo.impurity"
                maxlength="100"
                size="small"
              />
            </ws-form-item>
            <!--未回款（元）-->
            <ws-form-item label="未回款（元）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractProcessInfo.mildewGrain"
                maxlength="100"
                size="small"
              />
            </ws-form-item>

            <!--已完成发货量（吨）-->
            <ws-form-item label="已完成发货量（吨）" span="1" prop="contractNo">
              <ws-input
                v-model="deptBudgetList.contractProcessInfo.imperfectGrain"
                maxlength="100"
                size="small"
              />
            </ws-form-item>
            <!--双章原件回收情况-->
            <ws-form-item label="双章原件回收情况" span="1" prop="grade">
              <ws-select
                v-model="deptBudgetList.contractProcessInfo.grade"
                placeholder=""
                class="typeselect"
                @change="selectpackingMethod"
              >
                <ws-option
                  v-for="item in ChapterTwoList"
                  :key="item.constKey"
                  :label="item.constValue"
                  :value="item.constValue"
                />
              </ws-select>
            </ws-form-item>
          </ws-info-table>
        </ws-form>
      </div>

      <div class="wenzi">
        <h3>备注信息</h3>
      </div>
      <div class="ce">
        <ws-form
          ref="deptBudgetList"
          :rules="ruleDeptBudget"
          :model="deptBudgetList"
        >
          <!--备注信息-->
          <ws-input
            v-model="deptBudgetList.remarks"
            type="textarea"
            row="3"
            placeholder="请输入备注信息，不超过200字"
            maxlength="200"
          />
          <ws-upload
            ref="upload"
            table-name="maintain_work_order"
            oss-key="mainPlan"
            :comp-id="compId"
            :appendix-ids="appendixIdsAdd"
            :vesselId="deptBudgetList.addressUrl"
            :size-limit="size"
            @uploadSuccess="uploadSuccess"
            @onChange="onChange"
            accept=".jpg, .jpeg, .png, .pdf, .doc, .zip, .rar"
          />
        </ws-form>
      </div>
      <div style="text-align: right; padding: 10px" class="center">
        <el-button
          class="bg-bottom"
          type="primary"
          size="small"
          @click="submit()"
          >提交</el-button
        >
      </div>
    </div>
  </div>
</template>
<script>
// import { getVesselOne } from '@/model/procurement/basic'
// import { dayjs } from 'base-core-lib'
import { examineList, editInfo, packList } from '@/model/contarct/index'
export default {
  name: 'viewSpareMoney',
  watch: {
    vesselId(val) {
      this.getVesselData()
    },
    isShow(val) {
      this.showType = val
    },
  },
  data() {
    return {
      //弹出框
      dialogViewSpareMoney: false,
      dialogApproveFormVisible: false,
      // 船舶类型
      monetaryKey: null,
      // 表格显示数据
      tableDate: [],
      // 是否显示
      showType: true,
      // 年
      year: '',
      // 提交类型
      submitType: true,
      tableData: [{ date: 1111, name: 'qqqq', address: 'errrtt' }],
      pickerBeginDateBefore: {},
      // selectpackingMethod:{},
      selectunitList: {},
      //  change:{},
      unitList: {},
      packtypeList: {},
      compId: {},
      appendixIdsAdd: {},
      size: {},
      deptBudgetList: {},
      ruleDeptBudget: {},
      isEdited: false,
      registered: {},
      selectCrtDuty: {},
      dutyList: {},
      sexList: {},
      pickerBeginDateBefore: {},
      selectDuty: {},

      selectIntendedShip: {},
      interviewTypeList: {},
    }
  },
  activated() {
    //cg.viewBudget
    //cg.viewSpareMoney
    // this.getVesselData();
    this.loaddata()
    this.editInfo()
    this.showType = this.isShow
    console.log(this.$route.params)
    this.showType = this.isShow
  },
  methods: {
    // 关闭 dialog时 处理文件url 初始化upload组件
    handleClose() {
      this.dialogViewSpareMoney = false
    },
    returnsales() {
      this.$router.push({ path: 'salesContract' })
    },
    loaddata() {
      // 数据
      examineList({ id: this.$route.params.id })
        .toPromise()
        .then((response) => {
          this.deptBudgetList = response
        })
      // 包装方式
      packList({ constId: 'CON1' })
        .toPromise()
        .then((response) => {
          this.packtypeList = response
        })
      // 验收方式
      this.getUnitList()
      // 货名
      packList({ constId: 'CON2' })
        .toPromise()
        .then((response) => {
          this.goodnameList = response
        })
      // 品级
      packList({ constId: 'CON3' })
        .toPromise()
        .then((response) => {
          this.gradeList = response
        })
      // 双章
      packList({ constId: 'CON4' })
        .toPromise()
        .then((response) => {
          this.ChapterTwoList = response
        })
    },
    editInfo() {
      editInfo({})
    },
    // getList(){}
  },
}
</script>

<style lang="scss" scoped>
.button-container {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  width: 100%;
  height: 50px;
  padding: 0 10px;
  & > div {
    margin-left: 10px;
    display: flex;
    flex-wrap: nowrap;
    flex-direction: row;
    & > span {
      line-height: 50px;
    }
  }

  /deep/.auditFlow-box {
    position: unset;
    margin-left: 10px;
    &/deep/.auditFlow-icon {
      width: auto;
      padding-right: 30px;
    }
    &/deep/.auditFlow-main {
      position: absolute;
    }
  }
}
.box-app {
  display: inline-block;

  margin-left: 30px;
  line-height: 50px;
}
/deep/.el-dialog {
  .el-form-item {
    margin-bottom: 0 !important;
    .el-input--medium {
      textarea {
        min-height: 100px !important;
      }
    }
  }
}
.collapse-bottom {
  margin-bottom: 20px;
}
.input-main .textarea .el-textarea__inner {
  width: 100%;
  z-index: 1;
}
.bg-left {
  padding-left: 30px;
}
.bg-right {
  padding: 10px;
  text-align: right;
}
.bg-bottom {
  margin: 20px 0px;
}
.wenzi {
  width: 900px;
  margin: 0 auto;
}
.wenzi h3 {
  display: inline-block;
  left: 30px;
}
.wenzi p {
  display: inline-block;
}
.center {
  width: 900px;
  margin: 0 auto;
}
.el-form-item {
  width: 50%;
}
.el-form-item__label {
  text-align: center;
}
/*.crt-main .textarea /deep/ .el-form-item__label {*/
/*  height: 82px;*/
/*}*/
// 控制select为只读的时候显示样式

.hide-sel {
  .el-input__inner {
    border: 0px;
  }
  .el-icon-arrow-up {
    display: none;
  }
  .el-textarea__inner {
    background-color: #fff !important;
    border: 0;
  }
  .el-date-editor {
    i {
      display: none;
    }
  }
  .is-disabled {
    .el-input__inner:hover {
      background-color: #fff !important;
      border: 0;
    }
    color: #606266;
    .el-input__inner {
      background-color: #fff !important;
      border: 0;
      color: #606266;
    }
    .el-textarea__inner {
      background-color: #fff !important;
      border: 0;
      color: #606266;
    }
  }
}

// 控制select为只读的时候显示样式
/deep/.ws-class-table-col {
  height: auto;
  padding: 0px 2px;
  /deep/.el-input__inner {
    padding: 0px 2px;
  }
}
/deep/.is-disabled {
  .el-input__prefix,
  .el-input__suffix {
    display: none;
  }
  .el-input__inner {
    background-color: #fff;
    border-color: #fff !important;
    color: #000 !important;
    font-size: 14px;
    cursor: text;
    padding: 0 !important;
  }
}
.winseaview-view {
  padding: 10px 0 20px;
}
.container {
  overflow: scroll;
  height: 93vh;
}
</style>