<template>
  <div>
    <el-row
      :id="$route.query.state == 6 ? 'detail-main2' : ''"
      :class="{ is_detail: isExport }"
    >
      <div id="outInDepotEntrust"></div>
      <el-row style="text-align: center">
        <span class="title">天津市地方政府储备交易委托书</span>
      </el-row>
      <el-row style="margin-bottom: 20px">
        <div>
          <span style="float: left; font-weight: bold" class="songFont"
            >委托方信息</span
          >
          <span style="float: right" class="songFont"
            >委托编号：{{ fromData.wtbh }}</span
          >
        </div>
      </el-row>
      <el-form
        ref="fromData"
        :rules="rules"
        :model="fromData"
        label-width="130px"
      >
        <el-row>
          <el-col :span="11">
            <el-form-item prop="wtfbm" label="委托单位:">
              <el-input
                v-model="fromData.wtfmc"
                placeholder="请输入"
                class="inputwidth"
                :disabled="!isExport"
                v-if="!isExport"
              >
              </el-input>
              <span v-else>{{ fromData.wtfmc }}</span>
              <!-- <el-select
              v-model="fromData.wtfbm"
              placeholder="请选择"
              class="inputwidth"
              :disabled="showType"
              @change="cckdTodoName"
            >
              <el-option
                v-for="item in cckdOptions"
                :key="item.cgbh"
                :label="item.kdmc"
                :value="item.cgbh"
              ></el-option>
            </el-select> -->
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item prop="bzr" label="联系人及电话:">
              <el-input
                v-model="fromData.bzr"
                placeholder="请输入"
                class="inputwidth"
                :disabled="showType && !isExport"
                v-if="!isExport"
              >
              </el-input>
              <span v-else>{{ fromData.bzr }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item label="委托日期:" prop="wtrq">
              <el-input
                :disabled="!isExport"
                class="inputwidth"
                v-model="fromData.wtrq"
                v-if="!isExport"
              ></el-input>
              <span v-else>{{ fromData.wtrq }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item prop="jyrq" label="交易日期:">
              <el-date-picker
                v-model="fromData.jyrq"
                :disabled="showType && !isExport"
                class="inputwidth"
                type="date"
                placeholder="请选择"
                value-format="yyyy-MM-dd"
                v-if="!isExport"
              ></el-date-picker>
              <span v-else>{{ fromData.jyrq }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="fromData.jyfx.toString() != '采购'">
          <el-table
            class="tableMar"
            :data="fromData.seeSampleDOList"
            border
            fit
            highlight-current-row
          >
            <!-- <el-table-column align="center" label="序号" width="70">
            <template slot-scope="scope">
              <span>{{ scope.$index + 1 }}</span>
            </template>
          </el-table-column> -->

            <el-table-column align="center" prop="locale" label="看样地点">
              <!-- label-class-name="require_star" -->
              <template slot-scope="scope">
                <el-form-item label-width="0" v-if="!showType">
                  <!-- :prop="'seeSampleDOList.' + scope.$index + '.locale'" -->
                  <!-- :rules="rules.locale" -->
                  <el-input
                    v-model="scope.row.locale"
                    :disabled="showType"
                    class="inputwidth"
                    placeholder="请输入看样地点"
                  ></el-input>
                </el-form-item>
                <span v-else>{{ scope.row.locale }}</span>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="lxr" label="联系人及电话">
              <!-- label-class-name="require_star" -->
              <template slot-scope="scope">
                <el-form-item label-width="0" v-if="!showType">
                  <!-- :prop="'seeSampleDOList.' + scope.$index + '.lxr'"
                  :rules="rules.lxr" -->
                  <el-input
                    v-model="scope.row.lxr"
                    :disabled="showType"
                    class="inputwidth"
                    placeholder="请输入联系人及电话"
                  ></el-input>
                </el-form-item>
                <span v-else>{{ scope.row.lxr }}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="操作"
              v-if="!showType"
              width="70"
            >
              <template slot-scope="scope">
                <span
                  class="iconfont iconjianshao"
                  style="color: #4588db; cursor: pointer; font-size: 20px"
                  @click="deleteTableItemKy(scope.$index)"
                ></span> </template
            ></el-table-column>
          </el-table>
          <div class="addTable" v-if="!showType">
            <span class="iconfont iconzengjia" @click="addTableItemKy"></span>
          </div>
        </el-row>

        <el-row style="margin-bottom: 20px">
          <div>
            <span style="float: left; font-weight: bold" class="songFont"
              >委托内容</span
            >
          </div>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item prop="jyfx" label="交易方向:">
              <el-checkbox-group
                :disabled="!isExport"
                style="width: 100%"
                v-model="fromData.jyfx"
                v-if="!isExport"
              >
                <el-checkbox class="radioSize" label="采购"></el-checkbox>
                <el-checkbox class="radioSize" label="销售"></el-checkbox>
              </el-checkbox-group>
              <span v-else>{{
                fromData.jyfx.length > 0 ? fromData.jyfx.join("，") : ""
              }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item prop="jyfs" label="交易方式:">
              <el-radio-group
                :disabled="!isExport"
                style="width: 100%"
                v-model="fromData.jyfs"
                v-if="!isExport"
              >
                <el-radio class="radioSize" label="0">竞价</el-radio>
                <el-radio class="radioSize" label="1">挂牌</el-radio>
                <el-radio class="radioSize" label="2">购销双向</el-radio>
              </el-radio-group>
              <span v-if="isExport && fromData.jyfs == '0'">竞价</span>
              <span v-if="isExport && fromData.jyfs == '1'">挂牌</span>
              <span v-if="isExport && fromData.jyfs == '2'">购销双向</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item prop="lsxzbm" label="粮食性质">
              <el-radio-group
                :disabled="showType && !isExport"
                style="width: 100%"
                v-model="fromData.lsxzbm"
                v-if="!isExport"
              >
                <el-radio class="radioSize" label="1">市储</el-radio>
                <el-radio class="radioSize" label="2">区储</el-radio>
                <el-radio class="radioSize" label="3">市自</el-radio>
				<el-radio class="radioSize" label="4">市调</el-radio>
              </el-radio-group>
              <span v-if="isExport && fromData.lsxzbm == '1'">市储</span>
              <span v-if="isExport && fromData.lsxzbm == '2'">区储</span>
              <span v-if="isExport && fromData.lsxzbm == '3'">市自</span>
			  <span v-if="isExport && fromData.lsxzbm == '4'">市调</span>
            </el-form-item>
          </el-col>
		  <el-col :span='11'>
			<el-form-item
			label="轮换协议"
			  prop="lhxybh"
			>
			  <el-select
			    :disabled="showType"
			    clearable
			    class="inputwidth"
			    v-model="fromData.lhxybh"
			    placeholder="请选择协议"
			  >
			    <el-option
			      v-for="item in lhxyOptions"
			      :key="item.dictName"
			      :label="item.dictName"
			      :value="item.dictName"
			    ></el-option>
			  </el-select>
			</el-form-item>
		  </el-col>
        </el-row>
        <el-table
          class="tableMar"
          :data="fromData.goodsDOList"
          border
          fit
          highlight-current-row
        >
          <!-- <el-table-column align="center" label="序号" width="70">
            <template slot-scope="scope">
              <span>{{ scope.$index + 1 }}</span>
            </template>
          </el-table-column> -->

          <el-table-column
            align="center"
            prop="pzbm"
            label="交易品种"
            label-class-name="require_star"
          >
            <template slot-scope="scope">
              <el-form-item
                v-if="!showType"
                :prop="'goodsDOList.' + scope.$index + '.pzbm'"
                :rules="rules.pzbm"
                label-width="0"
              >
                <el-cascader
                  class="inputWidth"
                  :options="pzOptions"
                  :props="pzProps"
                  :show-all-levels="false"
                  v-model="scope.row.pzbm"
                  @change="getTableItemInfo($event, scope.row, scope.$index)"
                  placeholder="请选择"
                  :disabled="showType"
                ></el-cascader>
              </el-form-item>
              <span v-else>{{ scope.row.pzmc }}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="lsdj"
            label="等级"
            label-class-name="require_star"
          >
            <template slot-scope="scope">
              <el-form-item
                v-if="!showType"
                :prop="'goodsDOList.' + scope.$index + '.lsdj'"
                :rules="rules.lsdj"
                label-width="0"
              >
                <el-select
                  :disabled="showType"
                  clearable
                  class="inputwidth"
                  v-model="scope.row.lsdj"
                  placeholder="请选择等级"
                >
                  <el-option
                    v-for="item in djOptions"
                    :key="item.dictName"
                    :label="item.dictName"
                    :value="item.dictName"
                  ></el-option>
                </el-select>
              </el-form-item>
              <span v-else>{{ scope.row.lsdj }}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="scnd"
            label="生产年限"
            label-class-name="require_star"
          >
            <template slot-scope="scope">
              <el-form-item
                :prop="'goodsDOList.' + scope.$index + '.scnd'"
                :rules="rules.scnd"
                label-width="0"
                v-if="!showType"
              >
                <el-select
                  style="width: 90%"
                  v-model="scope.row.scnd"
                  placeholder="请选择"
                  :disabled="showType"
                  multiple
                >
                  <el-option
                    v-for="item in ndOptions"
                    :key="item"
                    :label="item"
                    :value="item"
                  ></el-option>
                </el-select>
                <!-- <el-date-picker
                  v-model="scope.row.scnd"
                  :disabled="showType"
                  class="inputwidth"
                  type="year"
                  placeholder="请选择"
                  value-format="yyyy"
                ></el-date-picker> -->
              </el-form-item>
              <span v-else>{{
                Array.isArray(scope.row.scnd)
                  ? scope.row.scnd.toString()
                  : scope.row.scnd
              }}</span>
            </template>
          </el-table-column>

          <el-table-column
            align="center"
            prop="lssl"
            label="数量(吨)"
            label-class-name="require_star"
          >
            <template slot-scope="scope">
              <el-form-item
                v-if="!showType"
                :prop="'goodsDOList.' + scope.$index + '.lssl'"
                :rules="rules.lssl"
                label-width="0"
              >
                <el-input
                  v-model="scope.row.lssl"
                  :disabled="showType"
                  class="inputwidth"
                  placeholder="请输入数量"
                ></el-input>
              </el-form-item>
              <span v-else>{{
                String(scope.row.lssl).indexOf(".") > -1
                  ? parseFloat(scope.row.lssl).toFixed(3)
                  : scope.row.lssl
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="jyfx"
            label="交易方向"
            label-class-name="require_star"
          >
            <template slot-scope="scope">
              <el-form-item
                :prop="'goodsDOList.' + scope.$index + '.jyfx'"
                :rules="rules.jyfx"
                label-width="0"
              >
                <el-select
                  :disabled="
                    fromData.jyfx.toString() != '采购,销售' && !isExport
                  "
                  v-model="scope.row.jyfx"
                  class="inputwidth"
                  clearable
                  v-if="!isExport"
                >
                  <el-option
                    v-for="item in tradeTypes"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
                <span v-else style="">{{
                  scope.row.jyfx == "1" ? "销售" : "采购"
                }}</span>
              </el-form-item>
            </template>
          </el-table-column>
		  <el-table-column align="center"
		    prop="lscd"
		    label="粮食产地/粮源地" label-class-name="require_star">
		    <template slot-scope="scope">
		      <el-form-item :prop="'goodsDOList.' + scope.$index + '.lscd'"
		      :rules="rules.lscd"
		      label-width="0">
		        <el-select
		          class="inputwidth"
		          multiple
		          :disabled="showType"
		          clearable
		          v-model="scope.row.lscd"
		          placeholder="请选择"
		        >
		          <el-option
		            v-for="item in cdOptions"
		            :key="item.dictName"
		            :label="item.dictName"
		            :value="item.dictName"
		          ></el-option>
		        </el-select>
		      </el-form-item>
		    </template>
		  </el-table-column>
          <el-table-column
            align="center"
            label="操作"
            v-if="!showType"
            width="70"
          >
            <template slot-scope="scope">
              <span
                class="iconfont iconjianshao"
                style="color: #4588db; cursor: pointer; font-size: 20px"
                @click="deleteTableItem(scope.$index)"
              ></span> </template
          ></el-table-column>
        </el-table>
        <div class="addTable" v-if="!showType">
          <span class="iconfont iconzengjia" @click="addTableItem"></span>
        </div>
       <!-- <el-row>
          <el-col :span="23">
            <el-form-item prop="lscd" label="粮食产地/粮源地">
              <el-select
                class="inputwidth"
                multiple
                :disabled="showType"
                clearable
                v-model="fromData.lscd"
                placeholder="请选择"
                v-if="!isExport"
              >
                <el-option
                  v-for="item in cdOptions"
                  :key="item.dictName"
                  :label="item.dictName"
                  :value="item.dictName"
                ></el-option>
              </el-select>
              <span v-else>{{
                fromData.lscd.length > 0 ? fromData.lscd.join("，") : ""
              }}</span>
            </el-form-item>
          </el-col>
        </el-row> -->
        <el-row>
          <!-- <el-col :span="11">
            <el-form-item prop="bzqDate" label="保质期限:">
              <el-date-picker
                :disabled="showType && !isExport"
                class="inputwidth"
                clearable
                v-model="fromData.bzqDate"
                type="daterange"
                range-separator="至"
                start-placeholder="最早一批日期"
                end-placeholder="最晚一批日期"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                v-if="!isExport"
              ></el-date-picker>
              <span v-else>{{
                fromData.bzqDate.length > 0
                  ? fromData.bzqDate[0] + " 至 " + fromData.bzqDate[1]
                  : ""
              }}</span>
            </el-form-item>
          </el-col> -->
		  <el-col :span="7">
		    <el-form-item prop="scrq" label="生产日期">
		      <el-date-picker
		        :disabled="showType"
		        class="inputwidth"
		        clearable
		        v-model="fromData.scrq"
		        type="date"
		        format="yyyy-MM-dd"
		        value-format="yyyy-MM-dd"
		      ></el-date-picker>
		    </el-form-item>
		  </el-col>
		  <el-col :span="7">
		    <el-form-item prop="bzq" label="保质期:">
		      <el-input
		        :disabled="showType"
		        class="inputwidth"
		        v-model="fromData.bzq"
		      ></el-input>
		    </el-form-item>
		  </el-col>
          <el-col :span="11">
            <el-form-item prop="wcsj" label="完成时间:">
              <el-date-picker
                v-model="fromData.wcsj"
                :disabled="showType && !isExport"
                class="inputwidth"
                type="date"
                placeholder="请选择"
                value-format="yyyy-MM-dd"
                v-if="!isExport"
              ></el-date-picker>
              <span v-else>{{ fromData.wcsj }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="fromData.jyfx.toString() == '采购,销售'">
          <el-col :span="23">
            <el-form-item label="购销价差(元/吨):" prop="gxcj">
              <el-input
                :disabled="showType && !isExport"
                class="inputwidth"
                v-model="fromData.gxcj"
                v-if="!isExport"
              ></el-input>
              <span v-else>{{ fromData.gxcj }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row style="margin-bottom: 20px">
          <div>
            <span style="float: left; font-weight: bold" class="songFont"
              >企业资质</span
            >
          </div>
        </el-row>
        <el-row>
          <el-col :span="23">
            <el-form-item label="报名企业要求:" prop="qybmyq">
              <el-input
                :disabled="showType && !isExport"
                class="inputwidth"
                v-model="fromData.qybmyq"
                v-if="!isExport"
              ></el-input>
              <span v-else>{{ fromData.qybmyq }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="23">
            <el-form-item label="资质:" prop="qyzz">
              <el-checkbox-group
                :disabled="showType && !isExport"
                style="width: 100%"
                v-model="fromData.qyzz"
                v-if="!isExport"
              >
                <el-checkbox class="radioSize" label="生产"></el-checkbox>
                <el-checkbox class="radioSize" label="经营"></el-checkbox>
                <el-checkbox class="radioSize" label="应急"></el-checkbox>
                <el-checkbox class="radioSize" label="进口"></el-checkbox>
              </el-checkbox-group>
              <span v-else>{{
                fromData.qyzz.length > 0 ? fromData.qyzz.join("，") : ""
              }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="23">
            <el-form-item label="承诺:" prop="commitment">
              <el-input
                v-if="!showType"
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 10 }"
                :disabled="showType"
                class="inputwidth"
                v-model="fromData.commitment"
              ></el-input>
              <span v-else v-html="fromData.commitment"></span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row style="margin-bottom: 20px">
          <div>
            <span style="float: left; font-weight: bold" class="songFont"
              >标准</span
            >
          </div>
        </el-row>
        <el-row v-if="fromData.jyfx.toString() != ''">
          <el-col :span="23">
            <el-form-item label="符合标准:" prop="fhbz">
              <!-- <el-input
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 10 }"
              :disabled="showType"
              class="inputwidth"
              v-model="fromData.fhbz"
            ></el-input> -->
              <kind-editor
                v-if="!showType"
                id="detailTextFhbz"
                height="150px"
                width="90%"
                :readonly="showType"
                :content="fromData.fhbz"
                pluginsPath="/static/kindeditor/plugins/"
                :loadStyleMode="false"
                @on-content-change="onContentChange($event, 'fhbz')"
              ></kind-editor>
              <span v-else v-html="fromData.fhbz"></span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="fromData.jyfx.toString() != '销售'">
          <el-col :span="23">
            <el-form-item label="检验项目要求:" prop="jyxmyq">
              <!-- <el-input
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 10 }"
              :disabled="showType"
              class="inputwidth"
              v-model="fromData.jyxmyq"
            ></el-input> -->
              <kind-editor
                v-if="!showType"
                id="detailTextJyxm"
                height="150px"
                width="90%"
                :readonly="showType"
                :content="fromData.jyxmyq"
                pluginsPath="/static/kindeditor/plugins/"
                :loadStyleMode="false"
                @on-content-change="onContentChange($event, 'jyxmyq')"
              ></kind-editor>
              <span v-else v-html="fromData.jyxmyq"></span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row style="margin-bottom: 20px">
          <div>
            <span style="float: left; font-weight: bold" class="songFont"
              >交易要求</span
            >
          </div>
        </el-row>
        <el-row>
          <el-col :span="23">
            <el-form-item label="竞价差值(元/吨):" prop="jjcz">
              <el-input
                :disabled="showType && !isExport"
                class="inputwidth"
                v-model="fromData.jjcz"
                v-if="!isExport"
              ></el-input>
              <span v-else>{{ fromData.jjcz }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="fromData.jyfx.toString() != '销售'">
          <el-col :span="23">
            <el-form-item label="包装要求:" prop="bzyq">
              <el-input
                v-if="!showType"
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 10 }"
                :disabled="showType"
                class="inputwidth"
                v-model="fromData.bzyq"
              ></el-input>
              <span v-else v-html="fromData.bzyq"></span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11">
            <el-form-item prop="jhfs" label="交货方式:">
              <el-radio-group
                :disabled="showType && !isExport"
                style="width: 100%"
                v-model="fromData.jhfs"
                v-if="!isExport"
              >
                <el-radio class="radioSize" label="1">库内价</el-radio>
                <el-radio class="radioSize" label="2">汽车车板价</el-radio>
              </el-radio-group>
              <span v-if="isExport && fromData.jhfs == '1'">库内价</span>
              <span v-if="isExport && fromData.jhfs == '2'">汽车车板价</span>
            </el-form-item>
          </el-col>
          <el-col :span="11">
            <el-form-item prop="jlfs" label="计量方式:">
              <!-- <el-radio-group
                :disabled="showType"
                style="width: 100%"
                v-model="fromData.jlfs"
              >
                <el-radio class="radioSize" label="1">地磅记录</el-radio>
                <el-radio class="radioSize" label="2">检斤计件</el-radio>
                <el-radio class="radioSize" label="3">其它</el-radio>
              </el-radio-group> -->
              <el-checkbox-group
                :disabled="showType && !isExport"
                style="width: 100%"
                v-model="fromData.jlfs"
                v-if="!isExport"
              >
                <el-checkbox class="radioSize" label="地磅记录"></el-checkbox>
                <el-checkbox class="radioSize" label="检斤计件"></el-checkbox>
                <el-checkbox class="radioSize" label="其它"></el-checkbox>
              </el-checkbox-group>
              <span v-else>{{
                fromData.jlfs.length > 0 ? fromData.jlfs.join("，") : ""
              }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="fromData.jyfx.toString() != '销售'">
          <el-col :span="11">
            <el-form-item prop="rkyq" label="入库要求">
              <!-- <el-radio-group
                :disabled="showType"
                style="width: 100%"
                v-model="fromData.rkyq"
              >
                <el-radio class="radioSize" label="1">第三方报告</el-radio>
                <el-radio class="radioSize" label="2">出厂报告</el-radio>
              </el-radio-group> -->
              <el-checkbox-group
                :disabled="showType && !isExport"
                style="width: 100%"
                v-model="fromData.rkyq"
                v-if="!isExport"
              >
                <el-checkbox class="radioSize" label="第三方报告"></el-checkbox>
                <el-checkbox class="radioSize" label="出厂报告"></el-checkbox>
              </el-checkbox-group>
              <span v-else>{{
                fromData.rkyq.length > 0 ? fromData.rkyq.join("，") : ""
              }}</span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="fromData.jyfx.toString() != '销售'">
          <el-col :span="23">
            <el-form-item label="第三方报告要求:" prop="sfbgyq">
              <el-input
                v-if="!showType"
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 10 }"
                :disabled="showType"
                class="inputwidth"
                v-model="fromData.sfbgyq"
              ></el-input>
              <span v-else v-html="fromData.sfbgyq"></span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="fromData.jyfx.toString() != '销售'">
          <el-col :span="23">
            <el-form-item label="出厂检验项目:" prop="ccjyxm">
              <el-input
                v-if="!showType"
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 10 }"
                :disabled="showType"
                class="inputwidth"
                v-model="fromData.ccjyxm"
              ></el-input>
              <span v-else v-html="fromData.ccjyxm"></span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="fromData.jyfx.toString() == '采购,销售'">
          <el-col :span="23">
            <el-form-item label="出入库顺序:" prop="crksx">
              <el-radio-group
                :disabled="showType && !isExport"
                style="width: 100%"
                v-model="fromData.crksx"
                v-if="!isExport"
              >
                <el-radio class="radioSize" label="1">先出后入</el-radio>
                <el-radio class="radioSize" label="2">先入后出</el-radio>
                <el-radio class="radioSize" label="3">其它</el-radio>
              </el-radio-group>
              <span v-if="isExport && fromData.crksx == '1'">先出后入</span>
              <span v-if="isExport && fromData.crksx == '2'">先入后出</span>
              <span v-if="isExport && fromData.crksx == '3'">其它</span>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="23">
            <el-form-item label="结算方式:" prop="jsfs">
              <el-input
                v-if="!showType"
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 10 }"
                :disabled="showType"
                class="inputwidth"
                v-model="fromData.jsfs"
              ></el-input>
              <span v-else v-html="fromData.jsfs"></span>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="23">
            <el-form-item label="备注:" prop="remark">
              <el-input
                v-if="!showType"
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 10 }"
                :disabled="showType"
                class="inputwidth"
                v-model="fromData.remark"
              ></el-input>
              <span v-else v-html="fromData.remark"></span>
            </el-form-item>
          </el-col>
        </el-row>
        <div style="margin-left: 110px">
          <span style="margin-left: -43px">说明：</span
          >1、委托方须在委托单位处加盖公章。<br />
          2、在所选项目的方框内打钩☑。<br />
          3、采用购销双向竞价交易方式的在交易数量、生产年限、粮食产地、粮源地等项分别填写。<br />
          4、报名企业要求填写企业所在地区及是否需开具增值税发票。<br />
          5、委托方其它要求填在备注格内。<br />
          6、委托方须遵守《天津市地方政府储备竞价采购/销售交易细则》及委托书对应公告的内容。<br />
          7、竞价差值为5或5的整数倍元/吨
        </div>
      </el-form>
    </el-row>
    <el-row class="btn-footer">
      <el-button type="primary" icon="iconfont iconxiayibu" @click="goToPage()"
        >下一页</el-button
      >
      <el-button
        v-if="!detailF"
        type="primary"
        icon="iconfont iconbaocun"
        @click="handleSave"
        >保存</el-button
      >
      <el-button
        v-if="$route.query.state == 6"
        type="primary"
        size="small"
        class="iconfont icondaochu11"
        @click="exportTable"
        >导出</el-button
      >
      <el-button
        type="primary"
        icon="iconfont iconfanhui"
        @click="$router.push('index')"
        >返回</el-button
      >
    </el-row>
  </div>
</template>

<script>
import {
  getPzOptions,
  getdjOptions,
  getDataGroup,
  selectkdxxList,
  queryProtocolCodeList
} from "@/api/transaction/tradeEntrust/outInDepotEntrust/index.js";
import { getNowDate, dateTimeFormat } from "@/utils/index";
import { getCodeName, getTreeVal } from "@/utils/statusList";
import { getDpz, zlbzList } from "./zlbz.js";
import KindEditor from "@/components/common/kindeditor";
import htmlToPdf from "@/utils/htmlToPdf";

export default {
  components: {
    KindEditor,
  },
  data() {
    return {
		lhxyOptions:[],
      detailF: false,
      pzProps: {
        label: "dictName",
        value: "dictCode",
        children: "subDataDictionarys",
        // checkStrictly: true,

        emitPath: false,
      },
      ndOptions: [
        new Date().getFullYear() - 10,
        new Date().getFullYear() - 9,
        new Date().getFullYear() - 8,
        new Date().getFullYear() - 7,
        new Date().getFullYear() - 6,
        new Date().getFullYear() - 5,
        new Date().getFullYear() - 4,
        new Date().getFullYear() - 3,
        new Date().getFullYear() - 2,
        new Date().getFullYear() - 1,
        new Date().getFullYear(),
        new Date().getFullYear() + 1,
        new Date().getFullYear() + 2,
        new Date().getFullYear() + 3,
        new Date().getFullYear() + 4,
        new Date().getFullYear() + 5,
        new Date().getFullYear() + 6,
        new Date().getFullYear() + 7,
        new Date().getFullYear() + 8,
        new Date().getFullYear() + 9,
        new Date().getFullYear() + 10,
      ],
      pzOptions: [],
      showType: false,
      fromData: {
		  lhxybh:'',//轮换协议
		  scrq:'',
		  bzq:'',
        wtfbm: "",
        wtfmc: "",
        bzr: "",
        wtrq: "",
        jyrq: "",
        lsxzbm: "",
        jyfs: "",
        jyfx: [],
        // lscd: [],
        wcsj: "",
        qyzz: [],
        qybmyq: "*********凡依法注册且能开具增值税专用发票企业",
        commitment:
          "1、我司按照**年**月**日天津市地方政府储备竞价交易公告和《天津市地方政府储备竞价采购/销售交易细则》履行责任和义务，如违约，按照要求缴纳违约金***元/吨。\n2、若委托成品粮交易我司确保每批次产品在保质期到期前20天完成出库。",
        fhbz: "",
        jyxmyq: "",
        jjcz: "10",
        bzyq: "",
        jhfs: "",
        jlfs: [],
        rkyq: [],
        sfbgyq:
          "成交企业须提供产地或发货地具备粮食检验检测资质的第三方机构出具的，本委托采购入库到货批次的产品检验合格报告原件,作为入库依据，其检验项目按上述要求为准。",
        ccjyxm: "",
        remark: "",
        jsfs: "采取货到付款方式，买方按验收入库进度，凭卖方开具的增值税专用发票每***吨进行结算，每仓最后一笔货款（不少于***吨）须由买方委托当地具备粮食检验检测资质机构对入库粮食进行扦样、检测，检测合格后方可结算。",
        goodsDOList: [
          {
			lscd: [],
            pzbm: "",
            pzmc: "",
            lsdj: "",
            scnd: [new Date().getFullYear()],
            lssl: "",
            jyfx: "0",
          },
        ],
        seeSampleDOList: [{ locale: "", lxr: "" }],
      },
      tradeTypes: [
        {
          label: "采购",
          value: "0",
        },
        {
          label: "销售",
          value: "1",
        },
      ],
      cckdOptions: [],
      rules: {
        wtfbm: [
          {
            required: true,
            message: "请选择储存库点",
            trigger: ["change"],
          },
        ],
        bzr: [
          {
            required: true,
            message: "请输入联系人及电话",
            trigger: ["blur"],
          },
        ],
        lxr: [
          {
            required: true,
            message: "请输入联系人及电话",
            trigger: ["blur"],
          },
        ],
        locale: [
          {
            required: true,
            message: "请输入看样地点",
            trigger: ["blur"],
          },
        ],
        jyrq: [
          {
            required: true,
            message: "请选择交易日期",
            trigger: ["change"],
          },
        ],
        lscd: [
          {
            required: true,
            message: "请选择粮食产地/粮源地",
            trigger: ["change"],
          },
        ],
        wcsj: [
          {
            required: true,
            message: "请选择完成时间",
            trigger: ["change"],
          },
        ],
        qybmyq: [
          {
            required: true,
            message: "请输入要求",
            trigger: ["blur"],
          },
        ],
        qyzz: [
          {
            required: true,
            message: "请选择资质",
            trigger: ["change"],
          },
        ],
        commitment: [
          {
            required: true,
            message: "请输入承诺",
            trigger: ["blur"],
          },
        ],
        fhbz: [
          {
            required: true,
            message: "请输入符合标准",
            trigger: ["blur", "change"],
          },
        ],
        jyxmyq: [
          {
            required: true,
            message: "请输入检验项目要求",
            trigger: ["blur", "change"],
          },
        ],
        jjcz: [
          {
            required: true,
            message: "请输入竞价差值",
            trigger: ["blur"],
          },
          {
            pattern: /^[1-9]\d{0,10}(\.\d{1,2})?$/,
            message: "请输入数字,保留两位小数",
          },
        ],
        gxcj: [
          {
            required: true,
            message: "请输入购销价差",
            trigger: ["blur"],
          },
        ],
        jhfs: [
          {
            required: true,
            message: "请选择交货方式",
            trigger: ["change"],
          },
        ],
        jlfs: [
          {
            required: true,
            message: "请选择计量方式",
            trigger: ["change"],
          },
        ],
        rkyq: [
          {
            required: true,
            message: "请选择入库要求",
            trigger: ["change"],
          },
        ],
        sfbgyq: [
          {
            required: true,
            message: "请输入第三方报告要求",
            trigger: ["blur"],
          },
        ],
        crksx: [
          {
            required: true,
            message: "请选择出入库顺序",
            trigger: ["change"],
          },
        ],
        jsfs: [
          {
            required: true,
            message: "请输入结算方式",
            trigger: ["blur"],
          },
        ],

        lsxzbm: [
          {
            required: true,
            message: "请选择粮食性质",
            trigger: ["change"],
          },
        ],
        pzbm: [
          {
            required: true,
            message: "请选择交易品种",
            trigger: ["change"],
          },
        ],
        lsdj: [
          {
            required: true,
            message: "请选择等级",
            trigger: ["change"],
          },
        ],
        scnd: [
          {
            required: true,
            message: "请选择生产年限",
            trigger: ["change"],
          },
        ],
        lssl: [
          { required: true, message: "请输入数量", trigger: "blur" },
          {
            pattern: /^[1-9]\d{0,10}(\.\d{1,3})?$/,
            message: "请输入数字,保留三位小数",
          },
        ],
      },
      cdOptions: [],
      djOptions: [],
      isExport: false,
    };
  },
  created() {
    // console.log(this.fromData.goodsDOList, "goodsDOList");
    this.addInfo();
    this.getInfo();
	this.GetLhxy()
  },
  mounted() {},
  methods: {
	  GetLhxy(){
	    var data={}
	    queryProtocolCodeList(data).then(res =>{
	      if(res.infoCode == 200){
	        this.lhxyOptions=res.data
	      }else{
			  this.$message({
				  type:'error',
				  message:res.msg
			  })
		  }
	    })
	  },
    exportTable() {
      // 获取要复制的元素
      this.isExport = true;
      setTimeout(() => {
        let src_ul = document.getElementById("detail-main2");
        htmlToPdf.downloadPDF(src_ul, "天津市地方政府储备交易委托书.pdf");
        setTimeout(() => {
          this.isExport = false;
        });
      }, 500);
      // let _that = this
      // setTimeout(() => {
      //   _that.$print(document.getElementById("detail-main2"));
      //   setTimeout(() => {
      //     _that.isExport = false
      //   });
      // },500);
    },
    handleSave() {
      this.$refs.fromData.validate((valid) => {
        if (valid) {
          this.$emit(
            "handleSave",
            this.fromData.jyfx.toString() == "采购"
              ? 2
              : this.fromData.jyfx.toString() == "销售"
              ? 3
              : 23
          );
        } else {
          this.$message({ type: "warning", message: "请正确填写信息！" });
        }
      });
    },
    onContentChange(val, name) {
      this.fromData[name] = val;
    },
    cckdTodoName(val) {
      this.fromData.wtfmc = getCodeName(val, this.cckdOptions, "cgbh", "kdmc");
    },
    getTableItemInfo(value, row, index) {
      row.pzmc = getTreeVal(this.pzOptions, value);
      console.log(this.fromData.jyfx, "this.fromData.jyfx");
      if (index == 0) {
        this.fromData.fhbz =
          zlbzList[getDpz(row.pzmc)]["符合标准"][
            this.fromData.jyfx.toString() == "销售" ? "销售" : "采购"
          ];

        // console.log(
        //   this.fromData.jyfx.toString() == "销售"? "销售" : "采购",
        //   row.pzmc,
        //   this.fromData.fhbz,
        //   "this.fromData.fhbz"
        // );
        this.fromData.jyxmyq = zlbzList[getDpz(row.pzmc)]["检测项目要求"];
      }
    },
    addInfo() {
      this.fromData.wtrq = getNowDate();
      this.fromData.wtfmc = sessionStorage.getItem("orgName");
      this.fromData.wtfbm = sessionStorage.getItem("orgCode");
      if (this.$route.query.jyfsAndlx) {
        switch (this.$route.query.jyfsAndlx) {
          case "1":
            this.fromData.jyfx = ["采购"];
            this.fromData.jyfs = "0";
            this.fromData.jyfsmc = "竞价";
            break;
          case "2":
            this.fromData.jyfx = ["采购"];
            this.fromData.jyfs = "1";
            this.fromData.jyfsmc = "挂牌";
            break;
          case "3":
            this.fromData.jyfx = ["销售"];
            this.fromData.jyfs = "0";
            this.fromData.jyfsmc = "竞价";
            this.fromData.jsfs =
              "成交企业一次性或分批次（每批次不低于****吨）将货款汇入******有限公司指定账户并办理出库手续。";
            break;
          case "4":
            this.fromData.jyfx = ["销售"];
            this.fromData.jyfs = "1";
            this.fromData.jyfsmc = "挂牌";
            this.fromData.jsfs =
              "成交企业一次性或分批次（每批次不低于****吨）将货款汇入******有限公司指定账户并办理出库手续。";
            break;
          case "5":
            this.fromData.jyfx = ["采购", "销售"];
            this.fromData.jyfs = "2";
            this.fromData.jyfsmc = "购销双向";
            this.fromData.jsfs =
              "1.入库时采取货到付款方式，入库完成后，由委托方对成交企业提供的具有粮食检验检测资质的第三方机构出具的入库产品检测合格报告进行审核，无误后，根据成交企业已入库的数量和其相对应数量开具的增值税专用发票办理结算。\n2.出库时采取款到付货方式，成交企业可一次性或分批次将货款汇入******有限公司指定账户方可办理出库。";
            this.fromData.remark =
              "1、采购：产品生产日期不得超过入库日期30天，粳米加工原粮要求为2021年生产的新粮。成交企业须保证同一合同入库粳米粒型一致，质量不低于原粳米质量。车辆到货后，每车抽包数量不少于当车数量的5%。\n2、销售：销售成交价格为承储单位发货仓库汽车板价，质量以粮食实际情况为准（库内看大货），数量以发货地点计件为准，出库损耗由成交企业承担。如出库有特殊要求，成交企业与出库单位协商并承担相关费用。\n3、涉及本委托书产品由我司交货出库后，因买方原因违反《中华人民共和国食品安全法》等法律法规要求的，所造成的一切后果及责任由买方自行承担。其他有关事宜按照《天津市地方政府储备竞价采购/销售交易细则》办理。";
            this.fromData.ccjyxm =
              "（检验报告需标注对应合同编号及标的物重量）色泽、气味、水分含量、加工精度、碎米总量（小碎米含量）、不完善粒含量、杂质总量（无机杂质含量）、黄粒米含量、互混率）。";
            this.fromData.bzyq =
              "产品包装统一并须符合GB7718-2011中相关预包装标准，包装物标准要求规格为25公斤普通编织袋（覆膜），产品包装须体现成交企业名称，每件产品净含量不得少于25公斤。不符合以上标准和要求的拒收。";
            break;
        }
      }
      console.log(this.fromData.jyfx, "this.fromData.jyfx");
      this.fromData.goodsDOList = [
        {
		  lscd: [],
          pzbm: "",
          pzmc: "",
          lsdj: "",
          scnd: [new Date().getFullYear()],
          lssl: "",
          jyfx:
            this.fromData.jyfx.length == 1
              ? this.fromData.jyfx.toString() == "采购"
                ? "0"
                : "1"
              : "",
        },
      ];
    },
    getInfo() {
      if (
        this.$route.query.state == 2 ||
        this.$route.query.state == 4 ||
        this.$route.query.state == 5 ||
        this.$route.query.state == 6
      ) {
        this.showType = true;
        this.detailF = true;
      }
      getDataGroup({ groupId: "AREA_CODE", pdictCode: "-1" }).then((res) => {
        if (res.infoCode == 200) {
          this.cdOptions = res.data;
        } else {
          this.$message.error(res.msg);
        }
      });
      // let detailsData = {
      //   company: sessionStorage.getItem("orgCode"),
      // };

      selectkdxxList().then((res) => {
        if (res.infoCode == "200") {
          this.cckdOptions = res.data;
        }
      });

      getPzOptions({ pdictCode: 11, groupId: "PM001" }).then((res) => {
        this.pzOptions = res.data;
      });
      getdjOptions("LSDJ").then((res) => {
        if (res.infoCode == 200) {
          this.djOptions = res.data;
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    addTableItem() {
      let data = {
		  lscd: [],
        pzbm: "",
        pzmc: "",
        lsdj: "",
        scnd: [new Date().getFullYear()],
        lssl: "",
        jyfx:
          this.fromData.jyfx.length == 1
            ? this.fromData.jyfx.toString() == "采购"
              ? "0"
              : "1"
            : "",
      };
      this.fromData.goodsDOList.push(data);
    },
    deleteTableItem(index) {
      if (this.fromData.goodsDOList.length == 1) {
        return;
      }
      this.fromData.goodsDOList.splice(index, 1);
    },
    addTableItemKy() {
      let data = {
        locale: "",
        lxr: "",
      };
      this.fromData.seeSampleDOList.push(data);
    },
    deleteTableItemKy(index) {
      if (this.fromData.seeSampleDOList.length == 1) {
        return;
      }
      this.fromData.seeSampleDOList.splice(index, 1);
    },
    goToPage() {
      this.$refs["fromData"].validate((valid) => {
        if (valid) {
          this.$emit("goToPage");
        } else {
          this.$message({ type: "warning", message: "请正确填写信息！" });
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.el-table /deep/ .cell.require_star:before {
  content: "*";
  color: red;
}
.tableMar {
  margin-bottom: 20px;
}
.title {
  margin-bottom: 20px;
  text-align: center;
  font-size: 16px;
}
.inputwidth {
  width: 90% !important;
}
.addTable {
  text-align: right;
  margin-right: 50px;
}

.addTable span {
  font-size: 20px;
  font-weight: bold;
  color: #4588db;
  cursor: pointer;
}
.btn-footer {
  text-align: center;
  margin: 20px;
}
#detail-main2 {
  padding: 70px 40px 40px 40px;
  height: 100%;
}
.is_detail {
  width: 1000px;
}
</style>
<style>
#outInDepotEntrust {
  position: relative;
}

#outInDepotEntrust > div {
  top: -17px !important;
  left: 295px !important;
}
</style>