<template>
  <div>
    <el-card :body-style="cardBodyStyle">
      <el-form :model="query" label-position="right" :inline="true">
        <el-row :gutter="10" style="margin-bottom: 5px;">
          <el-col :span="5">
            <el-form-item label="录入日期" style="margin-bottom: 5px;">
              <el-date-picker
                  style="width: 100%"
                  v-model="query.addTime"
                  type="daterange"
                  range-separator="-"
                  @select="aaa"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  value-format="YYYY-MM-DD"
              />
            </el-form-item>
          </el-col>
        </el-row>


      </el-form>
    </el-card>
    <!--    <el-card :body-style="cardBodyStyle">-->
    <!--      <el-button type="primary" @click="handleSearch" plain>查询</el-button>-->
    <!--      <el-button type="success" plain @click="insertDialog">新增</el-button>-->
    <!--      <el-button type="success" @click="submit" plain>提交审批</el-button>-->
    <!--    </el-card>-->
    <ButtonBar @handleSearch="handleSearch" @insertDialog="insertDialog" @download="searchReport" ></ButtonBar>

    <el-card :body-style="cardBodyStyle">
      <el-table :data="tableData" border highlight-current-row @selection-change="handleSelectionChange"
                :height="height">
        <el-table-column type="selection" fixed></el-table-column>
        <el-table-column type="index" label="序号" align="center" width="60" fixed="left">
          <template #default="scope">
            <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
          </template>
        </el-table-column>
        <!--        <el-table-column v-if="true" prop="compCd" label="公司名称" width="120" header-align="center"-->
        <!--                         align="center" show-overflow-tooltip>-->
        <!--        </el-table-column>-->
        <el-table-column v-if="true" prop="pricNo" label="定价编号" width="120" header-align="center" fixed="left"
                         align="center" show-overflow-tooltip>
          <template #default="scope">
            <el-button @click="handleInfo(scope.row)" type="primary" link>{{ scope.row.pricNo }}</el-button>
          </template>
        </el-table-column>
        <el-table-column v-if="true" prop="deptNm" label="部门名称" width="140" header-align="center"
                         align="center" show-overflow-tooltip>
        </el-table-column>

        <el-table-column v-if="true" prop="addName" label="录入人" header-align="center" align="center" width="140"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="addTime" label="录入日期" header-align="center" align="center"  width="180"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="lastUpdate" label="最后修改日期" header-align="center" align="center" width="180"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="addDeptName" label="添加部门" header-align="center" align="center"  width="140"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="remark" label="备注" header-align="center" align="center"
                         show-overflow-tooltip>
        </el-table-column>
        <el-table-column v-if="true" prop="workModel.flowStatusName" label="流程状态" width="120" header-align="center" align="center"
                         show-overflow-tooltip>
          <template #default="{ row }">
            <div>
              <el-tag v-if="row.workId !== undefined && row.workModel.flowStatus === '110'">{{ row.workModel.flowStatusName }}</el-tag>
              <el-tag type="success" v-else-if="row.workId !== undefined && row.workModel.flowStatus === '170'">{{ row.workModel.flowStatusName }}</el-tag>
              <el-tag type="danger" v-else-if="row.workId !== undefined && (row.workModel.flowStatus === '130' || row.workModel.flowStatus === '180' || row.workModel.flowStatus === '190')">{{ row.workModel.flowStatusName }}</el-tag>
              <el-tag type="warning" v-else>'---'</el-tag>
            </div>

          </template>
        </el-table-column>
        <el-table-column v-if="true" prop="workModel.flowNode" label="当前节点" width="120" header-align="center" align="center"
                         show-overflow-tooltip>
          <template #default="{ row }">
            <div>
              <el-tag v-if="row.workId !== undefined && row.workModel.flowStatus === '110'">{{ row.workModel.flowNode }}</el-tag>
              <el-tag type="success" v-else-if="row.workId !== undefined && row.workModel.flowStatus === '170'">{{ row.workModel.flowNode }}</el-tag>
              <el-tag type="danger" v-else-if="row.workId !== undefined && (row.workModel.flowStatus === '130' || row.workModel.flowStatus === '180' || row.workModel.flowStatus === '190')">{{ row.workModel.flowNode }}</el-tag>
              <el-tag type="warning" v-else>'---'</el-tag>
            </div>

          </template>
        </el-table-column>
<!--        <el-table-column v-if="true" prop="processInstanceStatusStr" label="流程状态" header-align="center"-->
<!--                         align="center"-->
<!--                         show-overflow-tooltip>-->
<!--        </el-table-column>-->
        <el-table-column label="查看" header-align="center" align="center" width="300px" fixed="right">
          <template #default="scope">
<!--            <el-button plain type="warning" @click="handleEdit(scope.row)">编辑</el-button>-->
<!--            <el-button plain type="danger" @click="handleDelete(scope.row )">删除</el-button>-->
            <div v-show="scope.row.status != 'true'">
              <el-button plain type="warning" @click="handleEdit(scope.row)" v-show="scope.row.workId === '' || scope.row.workModel.opType === '1'">编辑
              </el-button>
              <el-button plain type="danger" @click="handleDelete(scope.row )" v-show="scope.row.workId === '' || scope.row.workModel.opType === '1'">删除
              </el-button>
              <el-button plain type="success" @click="handleSubmit(scope.row ) " v-show="scope.row.workId === '' || scope.row.workModel.opType === '1'">发起
              </el-button>
              <el-button plain type="primary" @click="handleDetail(scope.row )" v-show="scope.row.workId !== ''">详情</el-button>
              <el-button plain type="info" @click="handleCancel(scope.row )" v-show="scope.row.workId !== '' && scope.row.workModel.opType !== '1' && scope.row.workModel.flowStatus !== '170'">撤回</el-button>
            </div>
            <div v-show="scope.row.status == 'true'">
              <el-button @click="handleInfo(scope.row)" type="primary" plain>查看</el-button>
            </div>

          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-card :body-style="cardBodyStyle">
      <el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="pageSizes" :total="totalRows"
                     background="background" layout="total, sizes, prev, pager, next, jumper"
                     @size-change="handleSizeChange"
                     @current-change="handleCurrentChange">
      </el-pagination>
    </el-card>

    <el-dialog class="diaClass" :close-on-click-modal="false" draggable title="新增" v-model="insertDialogShow"
               width="1300px" @close="dialogClose"
               top="5vh">

      <el-card :body-style="cardBodyStyle">
        <el-form :model="insertForm" :rules="rules" label-width="110" label-position="right" :inline="true">
          <el-row :gutter="10">
            <el-col :span="8">
              <el-form-item label="定价编号">
                <el-input disabled v-model="insertForm.pricNo"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="录入人">
                <el-input disabled v-model="insertForm.addName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="录入时间">
                <el-date-picker
                    disabled
                    style="width: 100%"
                    v-model="insertForm.addTime"
                    type="date"
                    value-format="YYYY-MM-DD"
                    placeholder=""
                    :size="size"
                />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="备注" prop="remark">
                <el-input
                    v-model="insertForm.remark"
                    :autosize="{ minRows: 2, maxRows: 4 }"
                    type="textarea"
                    placeholder="备注"
                />
              </el-form-item>
            </el-col>
          </el-row>

        </el-form>
      </el-card>

      <el-tabs type="border-card">
        <el-tab-pane label="定价行数据">
          <el-card :body-style="cardBodyStyle">
            <el-button type="success" @click="onAddItemWl" plain :disabled="pricNo_button">新增</el-button>
          </el-card>
          <el-card :body-style="cardBodyStyle">

            <el-table :data="tableDataWl" @cell-dblclick="tableEdit" border highlight-current-row>
              <el-table-column type="index" label="行号" align="center" width="60">
                <template #default="scope">
                  <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="itemCd" label="物料编码" header-align="center" align="center"
                               width="130"
                               show-overflow-tooltip>
                <template #header>
                  <span style="color: red">*</span>物料编码
                </template>
                <template #default="scope">
                  <span v-show="!scope.row.isEdit">
                    {{ scope.row.itemCd }}
                  </span>
                  <div :class="{'highlighted-cell': isCellHighlightedItemCd(scope.row)}">
                    <el-input
                        readonly
                        v-show="scope.row.isEdit"
                        v-model="scope.row.itemCd">
                    </el-input>
                  </div>

                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="itemNm" label="物料名称" header-align="center" align="center"
                               width="170"
                               show-overflow-tooltip>
                <template #header>
                  <span style="color: red">*</span>物料名称
                </template>
                <template #default="scope">
                  <span v-show="!scope.row.isEdit">
                    {{ scope.row.itemNm }}
                  </span>
                  <div :class="{'highlighted-cell': isCellHighlightedItemNm(scope.row)}">
                    <el-input
                        readonly
                        v-show="scope.row.isEdit"
                        v-model="scope.row.itemNm"
                    >
                      <template #append>
                        <el-button :icon="Search" @click=" handleWl(scope.$index )"/>
                      </template>
                    </el-input>
                  </div>
                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="startDt" label="开始执行期间" header-align="center" align="center"
                               width="200" show-overflow-tooltip>
<!--                <template #header>-->
<!--                  <span style="color: red">*</span>开始执行期间-->
<!--                </template>-->
                <template #default="scope">
                  <span v-show="!scope.row.isEdit">
                     <el-date-picker
                         disabled
                         style="width: 100%"
                         v-model="scope.row.startDt"
                         type="datetime"
                         placeholder=""
                         :size="size"
                     />
                  </span>
                  <div :class="{'highlighted-cell': isCellHighlightedStartDt(scope.row)}">
                    <el-date-picker
                        style="width: 100%"
                        @change="startDtChange(scope.$index)"
                        v-if="scope.row.isEdit"
                        v-model="scope.row.startDt"
                        type="datetime"
                        placeholder=""
                        :size="size"
                    />
                  </div>
                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="priceCash" label="现汇价格" header-align="center" align="center"
                               width="140"
                               show-overflow-tooltip>
<!--                <template #header>-->
<!--                  <span style="color: red">*</span>现汇价格-->
<!--                </template>-->
                <template #default="scope">
                  <span v-show="!scope.row.isEdit">
                    {{ scope.row.priceCash }}
                  </span>
                  <div :class="{'highlighted-cell': isCellHighlightedPriceCash(scope.row)}">
                    <el-input-number v-show="scope.row.isEdit" v-model="scope.row.priceCash"
                                     @change="priceCashChange(scope.$index)"
                                     style="width: 100%" min="0" :precision="2" :step="0.1" controls-position="right"
                    ></el-input-number>
                  </div>
                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="priceBill" label="承兑价格" header-align="center" align="center"
                               width="140"
                               show-overflow-tooltip>
<!--                <template #header>-->
<!--                  <span style="color: red">*</span>承兑价格-->
<!--                </template>-->
                <template #default="scope">
                  <span v-show="!scope.row.isEdit">
                    {{ scope.row.priceBill }}
                  </span>
                  <div :class="{'highlighted-cell': isCellHighlightedBill(scope.row)}">
                    <el-input-number v-show="scope.row.isEdit" v-model="scope.row.priceBill"
                                     @change="priceBillChange(scope.$index)"
                                     style="width: 100%" min="0" :precision="2" :step="0.1" controls-position="right"
                    ></el-input-number>
                  </div>
                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="transTasteSci" label="规格(品位)%" header-align="center" align="center"
                               width="120"
                               show-overflow-tooltip>
<!--                <template #header>-->
<!--                  <span style="color: red">*</span>规格-->
<!--                </template>-->
                <template #default="scope">
                  <span v-show="!scope.row.isEdit">
                    {{ scope.row.transTasteSci }}
                  </span>
                  <div :class="{'highlighted-cell': isCellHighlightedtransTasteSci(scope.row)}">
                    <el-select v-show="scope.row.isEdit"  v-model="scope.row.transTasteSci"  placeholder="规格(品位)%"  @change="transTasteSciChange(scope.$index)">
                      <el-option
                          v-for="item in 100"
                          :key="item"
                          :label="item"
                          :value="item"
                      />
                    </el-select>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="操作" header-align="center" align="center" fixed="right">
                <template #default="scope">
<!--                  <el-button plain type="warning" v-if="!scope.row.isEdit" @click="rowEdit(scope.row)">编辑</el-button>-->
<!--                  <el-button plain type="success" v-else @click="rowEditSave(scope.row , scope.$index)">保存</el-button>-->
<!--                  <el-button plain type="" @click="rowCopy(scope.row)">复制</el-button>-->
                  <el-button plain type="warning" @click="upriceUpdate(scope.row)">编辑</el-button>
                  <el-button plain type="danger" @click="rowRemove(scope.$index,scope.row )">删除</el-button>
                </template>
              </el-table-column>

            </el-table>
          </el-card>
        </el-tab-pane>
      </el-tabs>
      <el-tabs type="border-card">
        <el-tab-pane label="附件信息">
          <Attachment ref="AttachmentRefManual" :fId="fId" :uploadButton="uploadButton"></Attachment>
        </el-tab-pane>
      </el-tabs>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="success" plain @click="createNm" :loading="loading" v-if="pricNo_button">生成调价申请编码
          </el-button>
          <el-button type="success" plain @click="insertDialogSave" :disabled="pricNo_button" v-else>保存</el-button>
          <el-button type="danger" plain @click="insertDialogShow = false">关闭</el-button>
        </div>
      </template>


    </el-dialog>
    <el-dialog class="diaClass" :close-on-click-modal="false" draggable title="查看" v-model="detailsDialogShow"
               width="1200px" @close="dialogClose"
               top="5vh">

      <el-card :body-style="cardBodyStyle">
        <el-form :model="insertForm" :rules="rules" label-width="110" label-position="right" :inline="true">
          <el-row :gutter="10">
            <el-col :span="8">
              <el-form-item label="定价编号">
                <el-input readonly v-model="insertForm.pricNo"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="录入人">
                <el-input readonly v-model="insertForm.addName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="录入时间">
                <el-date-picker
                    disabled
                    style="width: 100%"
                    v-model="insertForm.addTime"
                    type="date"
                    value-format="YYYY-MM-DD"
                    placeholder=""
                    :size="size"
                />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="备注" prop="remark">
                <el-input
                    v-model="insertForm.remark"
                    :autosize="{ minRows: 2, maxRows: 4 }"
                    type="textarea"
                    placeholder="备注"
                />
              </el-form-item>
            </el-col>
          </el-row>

        </el-form>
      </el-card>

      <el-tabs type="border-card">
        <el-tab-pane label="定价行数据">
          <el-card :body-style="cardBodyStyle">

            <el-table :data="tableDataWl" @cell-dblclick="tableEdit" border highlight-current-row>
              <el-table-column type="index" label="行号" align="center" width="60">
                <template #default="scope">
                  <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="itemCd" label="物料编码" header-align="center" align="center"
                               width="150"
                               show-overflow-tooltip>
                <template #header>
                  <span style="color: red">*</span>物料编码
                </template>
                <template #default="scope">


                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="itemNm" label="物料名称" header-align="center" align="center"
                               width="170"
                               show-overflow-tooltip>
                <template #header>
                  <span style="color: red">*</span>物料名称
                </template>

              </el-table-column>
              <el-table-column v-if="true" prop="startDt" label="开始执行期间" header-align="center" align="center"
                               width="220" show-overflow-tooltip>
                <template #header>
                  <span style="color: red">*</span>开始执行期间
                </template>
                <template #default="scope">

                  <el-date-picker
                      disabled
                      style="width: 100%"
                      v-model="scope.row.startDt"
                      type="datetime"
                      placeholder=""
                      :size="size"
                  />

                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="priceCash" label="现汇价格" header-align="center" align="center"
                               width="140"
                               show-overflow-tooltip>
                <template #header>
                  <span style="color: red">*</span>现汇价格
                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="priceBill" label="承兑价格" header-align="center" align="center"

                               show-overflow-tooltip>
                <template #header>
                  <span style="color: red">*</span>承兑价格
                </template>
              </el-table-column>
              <el-table-column v-if="true" prop="transTasteSci" label="规格(品位)%" header-align="center" align="center"

                               show-overflow-tooltip>
<!--                <template #header>-->
<!--                  <span style="color: red">*</span>承兑价格-->
<!--                </template>-->
              </el-table-column>

            </el-table>
          </el-card>
        </el-tab-pane>
      </el-tabs>
      <el-tabs type="border-card">
        <el-tab-pane label="附件信息">
          <Attachment ref="AttachmentRefManual" :fId="fId" :uploadButton="uploadButton"></Attachment>
        </el-tab-pane>
      </el-tabs>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="danger" plain @click="detailsDialogShow = false">关闭</el-button>
        </div>
      </template>


    </el-dialog>

    <Popup_base_wl ref="PopupRefTwo" @receive-from-child="retu"></Popup_base_wl>

    <el-dialog :close-on-click-modal="false" draggable v-model="reportDialogVisible" width="900px" top="5vh">
      <fine-report ref="finereport" :reportPath="reportPath"></fine-report>
    </el-dialog>

    <el-dialog class="diaClass" :close-on-click-modal="false" draggable title="物料行新增" v-model="upriceInsert"
               width="45%"
               top="5vh">
      <el-card class="box-card">
        <el-form ref="formRef" :model="upriceForm" :rules="rulesPriceForm" label-width="110" label-position="right"
                 :inline="true">
          <el-row>
            <el-col :span="12">
              <el-form-item label="物料编码" prop="itemCd">
                <el-input v-model="upriceForm.itemCd" readonly>
                  <template #append>
                    <el-button :icon="Search" @click=" handleWl( )"/>
                  </template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="物料名称" prop="itemNm">
                <el-input v-model="upriceForm.itemNm" readonly>
                  <template #append>
                    <el-button :icon="Search" @click=" handleWl( )"/>
                  </template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="税率" prop="taxRate">
                <el-select v-model="upriceForm.taxRate" placeholder="请选择" clearable >
                  <el-option v-for="item in dictList.TAX_RATE" :key="item.dicCode" :label="item.dicName"
                             :value="item.dicCode" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12" v-if="tjfIf">
              <el-form-item label="规格(品位)%" prop="transTasteSci">
                <el-select  v-model="upriceForm.transTasteSci"  placeholder="规格(品位)%">
                  <el-option
                      v-for="item in 100"
                      :key="item"
                      :label="item"
                      :value="item"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-row v-if="tjfIf">
              <el-col :span="12">
                <el-form-item label="现汇不含税" prop="priceNoCash">
                  <el-input-number style="width: 100%" v-model="upriceForm.priceNoCash"  :precision="2" :step="0.1" disabled>
                  </el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="现汇含税" prop="priceCash">
                  <el-input v-model="upriceForm.priceCash" disabled>

                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="承兑不含税" prop="priceNoBill">
                  <el-input-number style="width: 100%" v-model="upriceForm.priceNoBill"  @input="priceNoCashInput" :precision="2" :step="0.1" >
                  </el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="承兑含税" prop="priceBill">
                  <el-input v-model="upriceForm.priceBill" disabled>
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row v-if="tjkIf">
              <el-col :span="12">
                <el-form-item label="现汇不含税" prop="priceNoCash">
                  <el-input v-model="upriceForm.priceNoCash" disabled>

                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="现汇含税" prop="priceCash">

                  <el-input-number style="width: 100%" v-model="upriceForm.priceCash" @input="tjkPriceCashInput" :precision="2" :step="0.1">
                  </el-input-number>
                </el-form-item>
              </el-col>

            </el-row>

            <el-row v-if="otherIf">
              <el-col :span="12">
                <el-form-item label="现汇不含税" prop="priceNoCash">
                  <el-input v-model="upriceForm.priceNoCash" disabled>

                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="现汇含税" prop="priceCash">
                  <el-input-number style="width: 100%" v-model="upriceForm.priceCash" @input="otherPriceCashInput" :precision="2" :step="0.1" >
                  </el-input-number>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="承兑不含税" prop="priceNoBill">
                  <el-input v-model="upriceForm.priceNoBill" disabled>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="承兑含税" prop="priceBill">
                  <el-input-number style="width: 100%" v-model="upriceForm.priceBill"  @input="otherPriceBillInput" :precision="2" :step="0.1" >
                  </el-input-number>
                </el-form-item>
              </el-col>
            </el-row>
            <el-col>
              <el-form-item label="开始执行期间" prop="startDt">
                <el-date-picker
                    v-model="upriceForm.startDt"
                    type="datetime"
                    placeholder=""
                />
              </el-form-item>
            </el-col>
          </el-row>

        </el-form>
      </el-card>


      <template #footer>
        <div class="dialog-footer">
          <el-button type="success" plain @click="priceInsertSave">保存</el-button>
          <el-button type="danger" plain @click="upriceInsert = false">取消</el-button>
        </div>
      </template>


    </el-dialog>
  </div>
</template>

<script setup>
import {
  ref,
  reactive,
  onMounted,
  getCurrentInstance
} from 'vue'
import {Search} from '@element-plus/icons-vue'
import dayjs from 'dayjs'

const {
  proxy
} = getCurrentInstance()


import style from '@/tools/style'

const cardBodyStyle = ref(style.card)

const tableStatus = reactive({
  tableRowEditIndex: undefined,
  tableColumnEditIndex: undefined,
})
import SearchBar from '@/components/SearchBar.vue';
import Popup_base_wl from "@/views/bas/Popup_base_wl.vue";
import Attachment from "@/components/Attachment.vue";
import ButtonBar from "@/components/ButtonBar.vue";
import {workflowCancel, workflowSubmit} from "@/tools/workflow.js";

const searchBarRef = ref(null)


/**
 *   查询
 */

const query = ref({
  birthDate: '',
  type: '',
  code: '',
  name: '',
  sex: '',
  contractType: '',
  contractFlag: '',
})
// 首 列表
const tableData = ref([])
// 物料 列表
const tableDataWl = ref([])
const tableDataTwo = ref([])


const handleSearch = () => {
  currentPage.value = 1
  getTableData()
}
const getTableData = () => {
  var url = 'sal/UpriceHead/query'
  var param = {
    page: currentPage.value,
    rows: pageSize.value,
    params: JSON.stringify(query.value)
  }
  proxy.$axios.get(url, param).then(response => {
    if (response.data.code == '0') {
      tableData.value = response.data.data.records
      totalRows.value = response.data.data.total
    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })
}
/**
 *   查询
 */
/**
 * 分页
 */
const currentPage = ref(1)
const totalRows = ref(0)
const pageSizes = ref([10, 20, 30, 40])
const pageSize = ref(10)
const handleSizeChange = (val) => {
  pageSize.value = val
  getTableData()
}
const handleCurrentChange = (val) => {
  currentPage.value = val
  getTableData()
}

const PopupMenuTreeRef = ref(null)
const showPop = () => {
  console.log('showPop')
  PopupMenuTreeRef.value.show()
}
/**
 * 新增表单form
 */
const insertForm = ref({
  id: '',
  remark: '',
  addTime: proxy.$dayjs(),

})

// 新增订单
const insertDialogShow = ref(false)
const detailsDialogShow = ref(false)
const insertDialog = () => {
  loading.value = false
  pricNo_button.value = true
  uploadButton.value = false
  fId.value = ''

  insertForm.value = {
    id: '',
    remark: '',
    addTime: proxy.$dayjs(),
    addName: localStorage.userDesc,
    addId: localStorage.userId,
    addCode: localStorage.userCode,
    addDeptId: JSON.parse(localStorage.dept)[0].id,
    addDeptCode: JSON.parse(localStorage.dept)[0].deptCode,
    addDeptName: JSON.parse(localStorage.dept)[0].deptName,
    compCd: JSON.parse(localStorage.deptTree)[0].deptCode,
    deptCd: JSON.parse(localStorage.dept)[0].deptCode,
    deptNm: JSON.parse(localStorage.dept)[0].deptName,
  }
  tableDataWl.value = []
  insertDialogShow.value = true
}
const insertDialogSave = () => {
  var url = 'sal/UpriceHead/save'
  var param = {
    json: JSON.stringify(insertForm.value),

  }
  proxy.$axios.post(url, param).then(response => {
    if (response.data.code == 0) {
      insertDialogShow.value = false
    } else {

      ElMessage({
        type: 'error',
        message: '操作失败' + response.data.msg
      })
    }
  });
}
const pricNo_button = ref(true)

// 生成调价申请编码
const createNm = () => {
  loading.value = true
  var url = 'sal/UpriceHead/save'
  var param = {
    json: JSON.stringify(insertForm.value),

  }
  proxy.$axios.post(url, param).then(response => {
    if (response.data.code == 0) {
      ElMessage({
        message: '生成定价编码成功',
        type: 'success',
      })

      insertForm.value = response.data.data
      fId.value = response.data.data.id
      pricNo_button.value = false
      uploadButton.value = true
    } else {

      ElMessage({
        type: 'error',
        message: '操作失败' + response.data.msg
      })
    }
  });
}
const multipleSelection = ref([])
const handleSelectionChange = (val) => {
  multipleSelection.value = val
}
// 提交审批
const submit = () => {
  if (multipleSelection.value.length < 1) {
    ElMessage({
      type: 'warning',
      message: '请选择要提交的数据!'
    })
    return
  }


  var ids = []
  for (var i = 0; i < multipleSelection.value.length; i++) {

    // if (multipleSelection.value[i].processInstanceStatus == 'Y'){
    //   ElMessage({
    //     type: 'warning',
    //     message: '勾选的第 ' + (i+1) +" 条数据，不允许重复提交，请取消！"
    //   })
    //   return;
    // }
    ids.push(multipleSelection.value[i].id)
  }

  var param = {
    ids: JSON.stringify(ids),
    status: 'Y'
  }
  var url = 'sal/UpriceHead/submit'
  ElMessageBox.confirm(
      '此操作将' + '提交' + '该数据, 是否继续?',
      '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
        draggable: true,
      }
  )
      .then(() => {
        proxy.$axios.post(url, param).then(response => {
          if (response.data.code == '0') {
            ElMessage({
              type: 'success',
              message: '提交' + '成功！',
            });

            getTableData()
          } else {
            ElMessage.error('操作失败！' + response.data.msg)
          }
        })
      })
      .catch(() => {
        ElMessage({
          type: 'info',
          message: '已取消',
        })
      })

}
// 校验
const rules = reactive({
  contrNo: [
    {required: true, message: 'Please input Activity name', trigger: 'blur'},
  ],
  ordTy: [
    {required: true, message: 'Please input Activity name', trigger: 'blur'},
  ],
  supplierNm: [
    {required: true, message: 'Please input Activity name', trigger: 'blur'},
  ],
  salTy: [
    {required: true, message: 'Please input Activity name', trigger: 'blur'},
  ],
  payMth: [
    {required: true, message: 'Please input Activity name', trigger: 'blur'},
  ],
  salMth: [
    {required: true, message: 'Please input Activity name', trigger: 'blur'},
  ],
  kczz: [
    {required: true, message: 'Please input Activity name', trigger: 'blur'},
  ],
  bz: [
    {required: true, message: 'Please input Activity name', trigger: 'blur'},
  ],
})
const rulesPriceForm = reactive({
  itemCd: [
    {required: true, message: '不允许为空', trigger: 'blur' | 'change'},
  ],
  itemNm: [
    {required: true, message: '不允许为空', trigger: 'blur' | 'change'},
  ],
  taxRate: [
    {required: true, message: '不允许为空', trigger: 'blur' | 'change'},
  ],
  startDt: [
    {required: true, message: '不允许为空', trigger: 'blur' | 'change'},
  ],
})

const otherQuery = () => {

}

// 首-列表 编辑
const handleEdit = (row) => {
  uploadButton.value = true
  pricNo_button.value = false
  if (row.processInstanceStatus == 'Y') {
    ElMessage({
      type: 'warning',
      message: '数据审批中，不允许操作！'
    })
    return
  }
  var url = 'sal/UpriceHead/queryByPK'
  var param = {
    id: row.id
  }
  proxy.$axios.get(url, param).then(response => {
    if (response.data.code == '0') {
      insertForm.value = response.data.data
      fId.value = row.id
    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })
  var urlLine = 'sal/UpriceLine/queryAll'
  var map = {
    id: row.id
  }
  var paramLine = {
    params: JSON.stringify(map)
  }
  proxy.$axios.get(urlLine, paramLine).then(response => {
    if (response.data.code == '0') {

      tableDataWl.value = response.data.data.records

    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })
  insertDialogShow.value = true

}

// 首-列表 编辑
const handleDelete = (row) => {
  if (row.processInstanceStatus == 'Y') {
    ElMessage({
      type: 'warning',
      message: '数据审批中，不允许操作！'
    })
    return
  }
  var url = 'sal/UpriceHead/remove'
  var param = {
    id: row.id
  }
  ElMessageBox.confirm(
      '确定删除本条记录?',
      '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
        draggable: true,
      }
  )
      .then(() => {
        proxy.$axios.get(url, param).then(response => {
          if (response.data.code == '0') {
            console.log(response.data.data)
            ElMessage({
              type: 'success',
              message: '删除成功！',
            });
            getTableData()
          } else {
            ElMessage.error('操作失败！' + response.data.msg)
          }
        })
      })
      .catch(() => {
        ElMessage({
          type: 'info',
          message: '已取消',
        })
      })
}

// 调价申请物料 -add row、
const onAddItemWl = () => {
  upriceInsert.value = true
  upriceForm.value = {}
  // tableDataWl.value.push({
  //   isEdit: true,
  //   itemCd: "",
  //   itemNm: "",
  //   startDt: "",
  //   priceCash: "",
  //   priceBill: "",
  // })
}
const tableRowInputRef = ref(null)
const rowEdit = (scope) => {
  scope.isEdit = true
}
const rowEditSave = (scope, index) => {
  scope.fId = insertForm.value.id
  scope.pricNo = insertForm.value.pricNo
  if (!scope.itemCd) {
    ElMessage({
      message: '请选择物料',
      type: 'warning',
    })
    tableDataWl.value[index].itemCdstatus = 'warning'
    tableDataWl.value[index].itemNmstatus = 'warning'
    return
  }
  if (!scope.startDt) {
    ElMessage({
      message: '请选择执行期间',
      type: 'warning',
    })
    tableDataWl.value[index].startDtstatus = 'warning'
    return
  }
  if (!scope.priceCash) {
    ElMessage({
      message: '现汇价格不允许为空，且不为0',
      type: 'warning',
    })
    tableDataWl.value[index].priceCashstatus = 'warning'
    return
  }
  if (!scope.priceBill) {
    ElMessage({
      message: '承兑价格不允许为空，且不为0',
      type: 'warning',
    })
    tableDataWl.value[index].priceBillstatus = 'warning'
    return
  }
  // if (!scope.transTasteSci) {
  //   ElMessage({
  //     message: '品位不允许为空',
  //     type: 'warning',
  //   })
  //   tableDataWl.value[index].transTasteScistatus = 'warning'
  //   return
  // }
  var url = 'sal/UpriceLine/save'
  var param = {
    json: JSON.stringify(scope),

  }
  proxy.$axios.post(url, param).then(response => {
    if (response.data.code == 0) {
      ElMessage({
        message: '数据添加成功',
        type: 'success',
      })
      scope.isEdit = false
      scope.id = response.data.data.id

    } else {

      ElMessage({
        type: 'error',
        message: '操作失败' + response.data.msg
      })
    }
  });
}

// 表格中input取消焦点,select变化
const onInputTableBlur = (scope) => {
  console.log('取消焦点', scope)
  tableStatus.tableRowEditIndex = undefined
  tableStatus.tableColumnEditIndex = undefined
  const id = scope.row.id
  const key = scope.column.property
  const value = scope.row[key]
  // 更新给后端的数据接口
  // 提交数据........
}

// 物料 行复制
const rowCopy = (row) => {


  tableDataWl.value.push({
    isEdit: true,
    itemCd: row.itemCd,
    itemNm: row.itemNm,
    startDt: row.startDt,
    priceCash: row.priceCash,
    priceBill: row.priceBill,
  })
}

// 物料 行删除
const rowRemove = (index, scope) => {
  tableDataWl.value.splice(index, 1)
  var url = 'sal/UpriceLine/remove'
  var param = {
    id: scope.id,

  }

  if (scope.id) {
    proxy.$axios.post(url, param).then(response => {
      if (response.data.code == 0) {
        // ElMessage({
        //   message: '数据删除成功',
        //   type: 'success',
        // })
      } else {
        ElMessage({
          type: 'error',
          message: '操作失败' + response.data.msg
        })
      }
    });
  }

}

const tableEdit = (row, column, cell, event) => {
  console.log("row", row)
  console.log("column", column)
  console.log("cell", cell)
  console.log("event", event)
  if (column.property === 'itemCd') {
    tableDataWl.forEach(item => {
      if (item.id === row.id) {
        item.xEdit = true
      }
    })
  }

}
const retu = (val) => {

  // tableDataWl.value[insertTableDataRow.value].itemCd = val.itemCd
  // tableDataWl.value[insertTableDataRow.value].itemNm = val.itemNm
  // tableDataWl.value[insertTableDataRow.value].itemCdstatus = 'success'
  // tableDataWl.value[insertTableDataRow.value].itemNmstatus = 'success'
  upriceForm.value.itemCd = val.itemCd
  upriceForm.value.itemNm = val.itemNm

  if (val.itemNm.includes("铁精粉")){
    tjfIf.value = true
    tjkIf.value = false
    otherIf.value = false
  } else if ( val.itemNm.includes("铜精矿") || val.itemNm == "金" || val.itemNm == "银" || val.itemNm == "铜" ){
    tjkIf.value = true
    tjfIf.value = false
    otherIf.value = false
  } else{
    tjfIf.value = false
    tjkIf.value = false
    otherIf.value = true
  }
  upriceForm.value.priceCash = ''
  upriceForm.value.priceNoCash = ''
  upriceForm.value.priceBill = ''
  upriceForm.value.priceNoBill = ''

}
const PopupRefTwo = ref(null)
const insertTableDataRow = ref(null)
const handleWl = (index) => {

  // insertTableDataRow.value = index
  PopupRefTwo.value.open()
}
const uploadButton = ref(false)
const cellHover = (row) => {
  console.log("row", row)

  if (row.isEdit === true) {
    uploadButton.value = true
  } else {
    uploadButton.value = false
  }
  fId.value = row.id
}

const fId = ref('')

const dialogClose = () => {
  tableDataWl.value = []
  uploadButton.value = false
  getTableData()
}

const aaa = (val) => {
  insertForm.value.startDt = val[0]
  insertForm.value.endDt = val[1]
}
const isCellHighlightedBill = (row) => {

  return row.priceBillstatus === 'warning'; // 根据状态高亮单元格
};
const isCellHighlightedtransTasteSci = (row) => {

  return row.transTasteScistatus === 'warning'; // 根据状态高亮单元格
};
const isCellHighlightedItemCd = (row) => {

  return row.itemCdstatus === 'warning'; // 根据状态高亮单元格
};
const isCellHighlightedItemNm = (row) => {

  return row.itemNmstatus === 'warning'; // 根据状态高亮单元格
};
const isCellHighlightedStartDt = (row) => {

  return row.startDtstatus === 'warning'; // 根据状态高亮单元格
};
const isCellHighlightedPriceCash = (row) => {

  return row.priceCashstatus === 'warning'; // 根据状态高亮单元格
};

const startDtChange = (index) => {
  tableDataWl.value[index].startDtstatus = 'success'
}
const priceCashChange = (index) => {
  tableDataWl.value[index].priceCashstatus = 'success'
}
const priceBillChange = (index) => {
  tableDataWl.value[index].priceBillstatus = 'success'
}
const transTasteSciChange = (index) => {
  tableDataWl.value[index].transTasteScistatus = 'success'
}

const addId = ref('')
const addCode = ref('')
const addName = ref('')
const addDeptId = ref('')
const addDeptCode = ref('')
const addDeptName = ref('')
const compCd = ref('')
addId.value = localStorage.userId
addCode.value = localStorage.userCode
addName.value = localStorage.userDesc
addDeptId.value = JSON.parse(localStorage.dept)[0].id
addDeptCode.value = JSON.parse(localStorage.dept)[0].deptCode
addDeptName.value = JSON.parse(localStorage.dept)[0].deptName
compCd.value = JSON.parse(localStorage.deptTree)[0].deptCode
const height = ref(600)
const updateViewportHeight = () => {
  height.value = window.innerHeight * 0.65
  console.log(window.innerHeight);
};
const loading = ref(false)
const handleInfo = (row) => {
  var url = 'sal/UpriceHead/queryByPK'
  var param = {
    id: row.id
  }
  proxy.$axios.get(url, param).then(response => {
    if (response.data.code == '0') {
      insertForm.value = response.data.data
      fId.value = row.id
    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })
  var urlLine = 'sal/UpriceLine/queryAll'
  var map = {
    id: row.id
  }
  var paramLine = {
    params: JSON.stringify(map)
  }
  proxy.$axios.get(urlLine, paramLine).then(response => {
    if (response.data.code == '0') {

      tableDataWl.value = response.data.data.records

    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })
  detailsDialogShow.value = true
}

const flowId = ref('SalUpriceFinance')
const handleSubmit = (row) => {
  ElMessageBox.confirm(
      '确定提交流程?',
      '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
        draggable: true,
      }
  ).then(() => {
    var obj = {
      id : row.id
    }
    var url = 'sal/UpriceLine/ifSp'

    proxy.$axios.post(url, obj).then(response => {
      if (response.data.code == 0) {
        if (response.data.data == false){
          return workflowSubmit(
              flowId.value,
              '定价申请审批流程',
              '初始化提交',
              JSON.stringify(obj),
              row.workId,
              row.trackId)
        } else {
          ElMessage({
            type: 'success',
            message: '审批成功'
          })
          getTableData()
        }
      } else {
        ElMessage({
          type: 'error',
          message: '操作失败' + response.data.msg
        })
      }
    }).then((result) => {
      if(result.status === 'success'){

        console.log(result)
        // 将结果返回的workId和trackId保存
        var url = 'sal/UpriceHead/submitFq'
        var process = {
          'id': row.id,
          'workId': result.workId,
          'trackId': result.trackId,
        }
        var param = {
          json: JSON.stringify(process),
        }
        proxy.$axios.post(url, param).then(response => {
          if (response.data.code === 0) {
            // form.value = response.data.data
            ElMessage({
              type: 'success',
              message: '提交审批成功',
            })
            getTableData()
          }
        })
      }
      else{
        ElMessage({
          type: 'error',
          message: '提交审批失败' + response.data.msg
        });
      }
    });

  }).catch(() => {
    ElMessage({
      type: 'info',
      message: '已取消提交',
    })
  })
}


const handleDetail = (row) => {
  if(row.workId === null){
    ElMessage({
      type: 'info',
      message: '无法查看',
    })
  }else {

    sessionStorage.setItem('workflowQuery', JSON.stringify({
      flowId: flowId.value,
      workId: row.workId,
      trackId: row.trackId,
      date:new Date().getTime()
    }))

    proxy.$router.push({
      path: '/workflow/detail',
    })

  }
}

const handleCancel = (row) => {
  ElMessageBox.confirm(
      '确定撤回审批?',
      '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
        draggable: true,
      }
  ).then(() => {
    return workflowCancel(row.workId, row.trackId);
  }).then((result) => {
    if(result.status === 'success'){
      ElMessage({
        type: 'success',
        message: '撤回审批成功',
      })
      getTableData()
    }else {
      ElMessage({
        type: 'error',
        message: '撤回审批失败，' + result.msg
      });
    }
  }).catch(() => {
    ElMessage({
      type: 'info',
      message: '已取消提交',
    })
  })
}
import FineReport from '@/components/report/FineReport.vue'
const reportPath = ref('')
const finereport = ref(null)
const reportDialogVisible = ref(false);
const searchReport = () => {
  var date = proxy.$dayjs().format('YYYY年MM月DD日')
  console.log(date)
  if (multipleSelection.value.length == 1){
    if (multipleSelection.value[0].processInstanceStatus == '170'){
      var list = []
      var url = 'workflow/process/history'
      var param = {
        workId: multipleSelection.value[0].workId
      }
      proxy.$axios.post(url, param).then(response => {
        if (response.data.code == '0') {
          list = response.data.data.records
          var spsj = list[0].actiontime
          var trj = list[0].username
          var trjsj = list[0].actiontime
          var cwb = ''
          var cwbsj = ''
          var sjfwb = ''
          var sjfwbsj = ''
          var fgld = ''
          var fgldsj = ''
          var zgld = ''
          var zgldsj = ''

          console.log("list ", list)
          for (let i = list.length - 1; i >= 0; i--) {
            if (list[i].nodeid === 'Node2') {
              cwb = list[i].username;
              cwbsj = list[i].actiontime;
              break;
            }
          }
          for (let i = list.length - 1; i >= 0; i--) {
            if (list[i].nodeid === 'Node3') {
              sjfwb = list[i].username;
              sjfwbsj = list[i].actiontime;
              break;
            }
          }
          for (let i = list.length - 1; i >= 0; i--) {
            if (list[i].nodeid === 'Node4') {
              fgld = list[i].username;
              fgldsj = list[i].actiontime;
              break;
            }
          }
          for (let i = list.length - 1; i >= 0; i--) {
            if (list[i].nodeid === 'Node5') {
              zgld = list[i].username;
              zgldsj = list[i].actiontime;
              break;
            }
          }


          reportPath.value = 'jlyypt/salUprice.cpt&para1='+ date +'&para2='+String(localStorage.getItem('userDesc')) + "&id="
              + multipleSelection.value[0].id
              +"&spsj="+spsj
              + "&trj=" +trj
              + "&trjsj=" +trjsj
              + "&cwb=" +cwb
              + "&cwbsj=" +cwbsj
              + "&sjfwb=" +sjfwb
              + "&sjfwbsj=" +sjfwbsj
              + "&fgld=" +fgld
              + "&fgldsj=" +fgldsj
              + "&zgld=" +zgld
              + "&zgldsj=" +zgldsj
          reportDialogVisible.value = true
          finereport.value.refresh()
        } else {
          ElMessage.error('操作失败！' + response.data.msg)
        }
      })
    } else {
      reportPath.value = 'jlyypt/salResult.cpt&para2='+String(localStorage.getItem('userDesc')) + "&id=" + multipleSelection.value[0].id
      reportDialogVisible.value = true
      finereport.value.refresh()
    }

    // pDate.value = monthQuery.value.monthValue.getFullYear() + String(monthQuery.value.monthValue.getMonth() + 1).padStart(2, '0')
    // pReportDate.value = formatDateToYYYYMMDD(new Date())

  } else {
    ElMessage({
      type: 'warning',
      message: '请选择一条数据！',
    })
  }

}

const upriceInsert = ref(false)
const upriceForm = ref({})
const getUprice = (val) => {
  if (upriceForm.value.itemNm.includes("铁精粉")){
    var url = 'sal/UpriceLine/getUpriceByNoBill'
    var param = {
      priceNoBill: val,
      taxRate: upriceForm.value.taxRate,
      scpeType: upriceForm.value.transTasteSci
    }
    proxy.$axios.get(url, param).then(response => {
      if (response.data.code == '0') {
        upriceForm.value.priceBill = response.data.data.priceBill
        upriceForm.value.priceCash = response.data.data.priceCash
        upriceForm.value.priceNoCash = response.data.data.priceNoCash
      } else {
        ElMessage.error('操作失败！' + response.data.msg)
      }
    })
  }

}
const tjkgetUprice = (val) => {
  var url = 'sal/UpriceLine/getUpriceByCash'
  var param = {
    priceCash: val,
    taxRate: upriceForm.value.taxRate,
  }
  proxy.$axios.get(url, param).then(response => {
    if (response.data.code == '0') {
      upriceForm.value.priceNoCash = response.data.data.priceNoCash
    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })

}
const othergetUpriceCash = (val) => {
  var url = 'sal/UpriceLine/getUpriceByCash'
  var param = {
    priceCash: val,
    taxRate: upriceForm.value.taxRate,
  }
  proxy.$axios.get(url, param).then(response => {
    if (response.data.code == '0') {
      upriceForm.value.priceNoCash = response.data.data.priceNoCash
    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })

}
const othergetUpriceBill = (val) => {
  var url = 'sal/UpriceLine/getUpriceByCash'
  var param = {
    priceCash: val,
    taxRate: upriceForm.value.taxRate,
  }
  proxy.$axios.get(url, param).then(response => {
    if (response.data.code == '0') {
      upriceForm.value.priceNoBill = response.data.data.priceNoCash
    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })

}

const dictList = ref({})
const tjfIf = ref(false)
const tjkIf = ref(false)
const otherIf = ref(false)
const dictData = () => {
  var url = 'framework/Common/querySelectorList'
  var param = {
    type: JSON.stringify(['TAX_RATE'])
  }
  proxy.$axios.get(url, param).then(response => {
    if (response.data.code == '0') {
      dictList.value = response.data.data
    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })

}
const priceNoCashInput = (val) =>{
  getUprice(val)
}
const tjkPriceCashInput = (val) =>{

  tjkgetUprice(val)
}
const otherPriceCashInput = (val) =>{

  othergetUpriceCash(val)
}
const otherPriceBillInput = (val) =>{

  othergetUpriceBill(val)
}

const priceInsertSave = () =>{
  upriceForm.value.fId = insertForm.value.id
  upriceForm.value.pricNo = insertForm.value.pricNo

  var url = 'sal/UpriceLine/save'
  var param = {
    json: JSON.stringify(upriceForm.value),

  }
  proxy.$axios.post(url, param).then(response => {
    if (response.data.code == 0) {
      ElMessage({
        message: '数据添加成功',
        type: 'success',
      })
      upriceInsert.value = false
      getTableLine(insertForm.value.id)
    } else {

      ElMessage({
        type: 'error',
        message: '操作失败' + response.data.msg
      })
    }
  });
}

const getTableLine = (val) =>{
  var urlLine = 'sal/UpriceLine/queryAll'
  var map = {
    id: val
  }
  var paramLine = {
    params: JSON.stringify(map)
  }
  proxy.$axios.get(urlLine, paramLine).then(response => {
    if (response.data.code == '0') {

      tableDataWl.value = response.data.data.records

    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })
}

const upriceUpdate = (row) =>{
  upriceInsert.value = true
  var urlLine = 'sal/UpriceLine/queryByPK'
  var paramLine = {
    id: row.id
  }
  proxy.$axios.get(urlLine, paramLine).then(response => {
    if (response.data.code == '0') {
      upriceForm.value = response.data.data
      debugger
      if (response.data.data.itemNm.includes("铁精粉")){
        tjfIf.value = true
        tjkIf.value = false
        otherIf.value = false
      } else if ( response.data.data.itemNm.includes("铜精矿") || response.data.data.itemNm == "金" || response.data.data.itemNm == "银" || response.data.data.itemNm == "铜" ){
        tjkIf.value = true
        tjfIf.value = false
        otherIf.value = false
      } else{
        tjfIf.value = false
        tjkIf.value = false
        otherIf.value = true
      }
    } else {
      ElMessage.error('操作失败！' + response.data.msg)
    }
  })

}

onMounted(() => {
  getTableData()
  updateViewportHeight()
  dictData()
  console.log(`the component is now mounted.`)
})
</script>

<style scoped>
::v-deep .diaClass .el-form-item {
  width: 100%
}

.el-form-item {
  width: 100%
}

::v-deep .el-dialog__body {
  background-color: #F2F6FC;
}

.el-date-editor--date {
  width: 100%;
}

.highlighted-cell {
  border: 1px solid red;
  border-radius: 5px;
  //padding: 1px;
  //color: #67c23a;
}
</style>
