Fixiaobai
2023-09-24 8a00af1f534f4dd7d90cf48985d0b4ca536b0784
src/components/view/sale.vue
@@ -1,112 +1,112 @@
<style scoped>
   .sale .title .el-button {
      height: 32px;
      border: 1px solid rgba(190, 190, 190, 0.44);
      box-shadow: 0px 2px 4px rgba(220, 220, 220, 0.41);
      padding: 0 12px;
   }
.sale .title .el-button {
   height: 32px;
   border: 1px solid rgba(190, 190, 190, 0.44);
   box-shadow: 0px 2px 4px rgba(220, 220, 220, 0.41);
   padding: 0 12px;
}
   .sale .title {
      margin-bottom: 10px;
      padding: 0 20px;
   }
.sale .title {
   margin-bottom: 10px;
   padding: 0 20px;
}
   .sale .title * {
      font-size: 16px;
   }
.sale .title * {
   font-size: 16px;
}
   .choose {
      padding: 21px 24px;
      display: flex;
      align-items: center;
      background-color: #fff;
      border-bottom: 3px solid rgb(245, 247, 251);
   }
.choose {
   padding: 21px 24px;
   display: flex;
   align-items: center;
   background-color: #fff;
   border-bottom: 3px solid rgb(245, 247, 251);
}
   .choose * {
      font-size: 14px;
   }
.choose * {
   font-size: 14px;
}
   .choose .el-button {
      height: 32px;
      border: 1px solid rgba(190, 190, 190, 0.44);
      box-shadow: 0px 2px 4px rgba(220, 220, 220, 0.41);
      padding: 0 12px;
   }
.choose .el-button {
   height: 32px;
   border: 1px solid rgba(190, 190, 190, 0.44);
   box-shadow: 0px 2px 4px rgba(220, 220, 220, 0.41);
   padding: 0 12px;
}
   .thing {
      width: calc(100% - 44px);
      height: calc(100% - 42px - 82px - 66px);
      background-color: #fff;
      overflow: auto;
      padding: 33px 22px;
   }
.thing {
   width: calc(100% - 44px);
   height: calc(100% - 42px - 82px - 66px);
   background-color: #fff;
   overflow: auto;
   padding: 33px 22px;
}
   .table_do {
      color: #004ea0;
      cursor: pointer;
   }
.table_do {
   color: #004ea0;
   cursor: pointer;
}
   .select-model .body {
      padding: 0 20px;
      color: #333;
      max-height: 72vh;
      overflow-y: auto;
   }
.select-model .body {
   padding: 0 20px;
   color: #333;
   max-height: 72vh;
   overflow-y: auto;
}
   .select-model .head {
      font-size: 16px;
      color: #333;
      line-height: 40px;
   }
.select-model .head {
   font-size: 16px;
   color: #333;
   line-height: 40px;
}
   .select-model .content * {
      font-size: 14px;
   }
.select-model .content * {
   font-size: 14px;
}
   .select-model .content .value {
      font-size: 14px;
      padding: 0 15px;
      background-color: rgba(0, 0, 0, 0.05);
      border: 1px solid rgba(0, 0, 0, 0.1);
      border-radius: 4px;
   }
.select-model .content .value {
   font-size: 14px;
   padding: 0 15px;
   background-color: rgba(0, 0, 0, 0.05);
   border: 1px solid rgba(0, 0, 0, 0.1);
   border-radius: 4px;
}
</style>
<style>
   .sale .title .el-button * {
      font-size: 14px;
   }
.sale .title .el-button * {
   font-size: 14px;
}
   .sale .title .el-button--default {
      color: #004EA2;
   }
.sale .title .el-button--default {
   color: #004EA2;
}
   .sale .thing * {
      font-size: 14px;
   }
.sale .thing * {
   font-size: 14px;
}
   .sale .has-gutter .el-table__cell {
      background-color: #F0F1F5 !important;
      color: #333;
   }
.sale .has-gutter .el-table__cell {
   background-color: #F0F1F5 !important;
   color: #333;
}
   .sale .has-gutter .el-table__cell .cell {
      font-size: 16px;
      font-weight: 500;
   }
.sale .has-gutter .el-table__cell .cell {
   font-size: 16px;
   font-weight: 500;
}
   .sale .cell {
      color: #333;
      padding-left: 17px !important;
   }
.sale .cell {
   color: #333;
   padding-left: 17px !important;
}
   .sale .el-table__body-wrapper {
      height: 100%;
   }
.sale .el-table__body-wrapper {
   height: 100%;
}
   .sale .el-table__body {
      height: 100%;
   }
.sale .el-table__body {
   height: 100%;
}
</style>
<template>
@@ -115,8 +115,9 @@
         <el-row>
            <el-col :span="12" style="line-height: 32px;">销售管理</el-col>
            <el-col :span="12" style="text-align: right;">
               <el-button type="success" @click="syncOrder"
                  :icon="isSync ? 'el-icon-loading' : 'el-icon-refresh'">同步</el-button>
               <el-button type="primary" icon="el-icon-plus" @click="openAddDia">新增</el-button>
               <!-- <el-button icon="el-icon-edit-outline">修改</el-button> -->
               <el-button icon="el-icon-delete" @click="delSales">删除</el-button>
               <el-button icon="el-icon-download">导出</el-button>
            </el-col>
@@ -124,19 +125,20 @@
      </div>
      <div class="choose">
         <span>订单编号:</span>
         <el-input v-model="search.code" size="small" placeholder="请输入" style="width: 224px;margin-right: 30px;"
         <el-input v-model="search.code" size="small" placeholder="请输入" style="width: 13vw;margin-right: 5px;"
            clearable></el-input>
         <span>产品名称:</span>
         <el-input v-model="search.name" size="small" placeholder="请输入" style="width: 224px;margin-right: 30px;"
         <el-input v-model="search.name" size="small" placeholder="请输入" style="width: 13vw;margin-right: 5px;"
            clearable></el-input>
         <span>状态:</span>
         <el-select v-model="search.type" size="small" placeholder="请选择" style="width: 224px;margin-right: 30px;">
         <el-select v-model="search.type" size="small" placeholder="请选择" style="width: 13vw;margin-right: 5px;">
            <el-option label="全部" :value="null"></el-option>
            <el-option label="未审核" :value="2"></el-option>
            <el-option label="通过" :value="1"></el-option>
            <el-option label="不通过" :value="0"></el-option>
         </el-select>
         <span>交货日期:</span>
         <el-date-picker v-model="search.delTime" size="small" placeholder="请输入" style="width: 224px;margin-right: 30px;"
         <el-date-picker v-model="search.delTime" size="small" placeholder="请输入" style="width: 13vw;margin-right: 5px;"
            clearable value-format="yyyy-MM-dd"></el-date-picker>
         <el-button size="mini" @click="clean()"><span>重 置</span></el-button>
         <el-button size="mini" type="primary" style="background: #004EA2;" @click="selectRawInspectsList()">
@@ -153,58 +155,67 @@
            </el-table-column>
            <el-table-column prop="order_number" label="订单编号" width="150">
            </el-table-column>
            <el-table-column label="订单类型" width="100">
               <template slot-scope="scope">
                  <el-tag effect="dark" size="mini" style="font-size: 8px;">{{ scope.row.order_type }}</el-tag>
               </template>
            </el-table-column>
            <el-table-column prop="code" label="合同编号" width="220">
            </el-table-column>
            <el-table-column prop="name" label="工程名称">
            <el-table-column prop="name" label="工程名称" width="120">
            </el-table-column>
            <el-table-column prop="proname" label="客户名称">
            <el-table-column prop="proname" label="客户名称" width="120">
            </el-table-column>
            <el-table-column prop="交货日期" label="交货日期" width="150">
            </el-table-column>
            <el-table-column prop="note" label="备注" width="150" show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="type" label="状态" width="100">
               <template slot-scope="scope">
                  <span style="color: #34BD66;" v-if="scope.row.type==1">通过</span>
                  <span style="color: #E84738;" v-else-if="scope.row.type==0">不通过</span>
                  <span v-else></span>
                  <span style="color: #34BD66;" v-if="scope.row.type == 1">通过</span>
                  <span style="color: #E84738;" v-else-if="scope.row.type == 0">不通过</span>
                  <span v-else>{{ null }}</span>
               </template>
            </el-table-column>
            <el-table-column label="操作" width="220">
               <template slot-scope="scope">
                  <span class="table_do" @click="changeShowDetail(scope.row)">&nbsp;查看详情&nbsp;</span>
                  <span class="table_do" v-if="scope.row.type==null" @click="saleCheck(scope)">&nbsp;审核&nbsp;</span>
                  <span class="table_do" @click="downloadFile(scope.row)">&nbsp;下载附件&nbsp;</span>
                  <span class="table_do" v-if="scope.row.type == 2" @click="saleCheck(scope)">&nbsp;审核&nbsp;</span>
                  <span class="table_do" v-else>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                  <span class="table_do" v-if="scope.row.type==null" @click="openUpDia(scope.row.id)">&nbsp;编辑&nbsp;</span>
                  <span class="table_do" v-if="scope.row.type == 2"
                     @click="openUpDia(scope.row.id)">&nbsp;编辑&nbsp;</span>
                  <span class="table_do" v-else>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                  <span class="table_do" @click="delSale(scope.$index)">&nbsp;删除&nbsp;</span>
               </template>
            </el-table-column>
         </el-table>
         <el-col style="height: 50px;display: flex;align-items: center;justify-content: right;">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
               :page-sizes="[10, 20, 30, 50]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
               :total="countSize">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
               :current-page="currentPage" :page-sizes="[10, 20, 30, 50]" :page-size="pageSize"
               layout="total, sizes, prev, pager, next, jumper" :total="countSize">
            </el-pagination>
         </el-col>
      </div>
      <div class="select-model">
         <el-dialog title="销售详情" :visible.sync="selectDia" width="750px">
            <div class="body" v-if="oneData!=null">
            <div class="body" v-if="oneData != null">
               <div class="head">基本信息</div>
               <div class="content">
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">订单编号</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.orderNumber}}</div>
                        <div class="value">{{ oneData.orderNumber }}</div>
                     </el-col>
                     <el-col :span="3" :offset="2">合同编号</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.code}}</div>
                        <div class="value">{{ oneData.code }}</div>
                     </el-col>
                  </el-row>
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">工程名称</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.name}}</div>
                        <div class="value">{{ oneData.name }}</div>
                     </el-col>
                     <el-col :span="3" :offset="2">状态</el-col>
                     <el-col :span="8">
@@ -213,53 +224,43 @@
                        <div class="value" v-else>&nbsp;</div>
                     </el-col>
                  </el-row>
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">备注</el-col>
                     <el-col :span="21">
                        <div style="width: 95%;word-wrap: break-word;" class="value">{{ oneData.note }}</div>
                     </el-col>
                  </el-row>
               </div>
               <div class="head">客户信息</div>
               <div class="content">
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">客户名称</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.proname}}</div>
                        <div class="value">{{ oneData.proname }}</div>
                     </el-col>
                     <el-col :span="3" :offset="2">收货地址</el-col>
                     <el-col :span="3" :offset="2">业务员</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.adress}}</div>
                        <div class="value">{{ oneData.saleman }}</div>
                     </el-col>
                  </el-row>
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">联系人</el-col>
                     <el-col :span="3">下单人</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.username}}</div>
                        <div class="value">{{ oneData.orderName }}</div>
                     </el-col>
                     <el-col :span="3" :offset="2">联系电话</el-col>
                     <el-col :span="3" :offset="2">交货日期</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.phone}}</div>
                     </el-col>
                  </el-row>
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">业务员</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.saleman}}</div>
                     </el-col>
                     <el-col :span="3" :offset="2">下单人</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.orderName}}</div>
                     </el-col>
                  </el-row>
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">交货日期</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.delTime}}</div>
                     </el-col>
                     <el-col :span="3" :offset="2">审核人</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.checkname==null?'&nbsp;': oneData.checkname}}</div>
                        <div class="value">{{ oneData.delTime }}</div>
                     </el-col>
                  </el-row>
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">审核日期</el-col>
                     <el-col :span="8">
                        <div class="value">{{oneData.checkTime==null?'&nbsp;': oneData.checkTime}}</div>
                        <div class="value">{{ oneData.checkTime == null ? '&nbsp;' : oneData.checkTime }}</div>
                     </el-col>
                     <el-col :span="3" :offset="2">审核人</el-col>
                     <el-col :span="8">
                        <div class="value">{{ oneData.checkname == null ? '&nbsp;' : oneData.checkname }}</div>
                     </el-col>
                  </el-row>
               </div>
@@ -276,20 +277,28 @@
                     </el-table-column>
                     <el-table-column prop="price" label="单价">
                     </el-table-column>
                     <el-table-column prop="username" label="联系人">
                     </el-table-column>
                     <el-table-column prop="phone" label="联系电话">
                     </el-table-column>
                     <el-table-column prop="address" label="地址">
                     </el-table-column>
                  </el-table>
               </div>
            </div>
         </el-dialog>
      </div>
      <div class="select-model">
         <el-dialog :title="`销售${upDia==true?'修改':'新增'}`" :visible.sync="addDia" width="850px">
         <el-dialog :title="`销售${upDia == true ? '修改' : '新增'}`" :visible.sync="addDia" width="900px"
            @close="closeDialog">
            <div class="body">
               <div class="head">基本信息</div>
               <div class="content">
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">订单编号</el-col>
                     <el-col :span="8">
                        <el-input v-model="addData.orderNumber" size="small" placeholder="请输入订单编号" clearable></el-input>
                        <el-input v-model="addData.orderNumber" size="small" placeholder="请输入订单编号"
                           clearable></el-input>
                     </el-col>
                     <el-col :span="3" :offset="2">合同编号</el-col>
                     <el-col :span="8">
@@ -301,6 +310,10 @@
                     <el-col :span="8">
                        <el-input v-model="addData.name" size="small" placeholder="请输入工程名称" clearable></el-input>
                     </el-col>
                     <el-col :span="3" :offset="2">备注</el-col>
                     <el-col :span="8">
                        <el-input v-model="addData.note" size="small" placeholder="请输入备注" clearable></el-input>
                     </el-col>
                  </el-row>
               </div>
               <div class="head">客户信息</div>
@@ -310,37 +323,25 @@
                     <el-col :span="8">
                        <el-input v-model="addData.proname" size="small" placeholder="请输入客户名称" clearable></el-input>
                     </el-col>
                     <el-col :span="3" :offset="2">收货地址</el-col>
                     <el-col :span="3" :offset="2">交货日期</el-col>
                     <el-col :span="8">
                        <el-input v-model="addData.adress" size="small" placeholder="请输入收货地址" clearable></el-input>
                     </el-col>
                  </el-row>
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">联系人</el-col>
                     <el-col :span="8">
                        <el-input v-model="addData.username" size="small" placeholder="请输入联系人" clearable></el-input>
                     </el-col>
                     <el-col :span="3" :offset="2">联系电话</el-col>
                     <el-col :span="8">
                        <el-input v-model="addData.phone" size="small" placeholder="请输入联系电话" clearable></el-input>
                        <el-date-picker v-model="addData.delTime" size="small" placeholder="请输入交货日期" clearable
                           value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
                     </el-col>
                  </el-row>
                  <el-row style="line-height: 30px;margin: 15px 0;">
                     <el-col :span="3">下单人</el-col>
                     <el-col :span="8">
                        <el-input v-model="addData.orderName" size="small" placeholder="请输入下单人" clearable></el-input>
                     </el-col>
                     <el-col :span="3" :offset="2">交货日期</el-col>
                     <el-col :span="8">
                        <el-date-picker v-model="addData.delTime" size="small" placeholder="请输入交货日期" clearable
                           value-format="yyyy-MM-dd"></el-date-picker>
                        <el-input v-model="addData.orderName" size="small" placeholder="请输入下单人"
                           clearable></el-input>
                     </el-col>
                  </el-row>
               </div>
               <div class="head" style="line-height: 50px;">
                  <el-col :span="12">产品信息</el-col>
                  <el-col :span="12" style="text-align: right;">
                     <el-button size="mini" @click="addSaleMaterial"><span style="font-size: 12px;">添加行</span></el-button>
                     <el-button size="mini" @click="addSaleMaterial"><span
                           style="font-size: 12px;">添加行</span></el-button>
                  </el-col>
               </div>
               <div class="content">
@@ -353,37 +354,56 @@
                     </el-table-column>
                     <el-table-column prop="specifications" label="规格型号" width="180">
                        <template slot-scope="scope">
                           <el-input v-model="scope.row.specifications" size="small" clearable placeholder="请输入规格型号"></el-input>
                           <el-input v-model="scope.row.specifications" size="small" clearable
                              placeholder="请输入规格型号"></el-input>
                        </template>
                     </el-table-column>
                     <el-table-column prop="unit" label="单位">
                     <el-table-column prop="unit" label="单位" width="100">
                        <template slot-scope="scope">
                           <el-input v-model="scope.row.unit" size="small" clearable placeholder="请输入"></el-input>
                        </template>
                     </el-table-column>
                     <el-table-column prop="number" label="数量">
                     <el-table-column prop="number" label="数量" width="100">
                        <template slot-scope="scope">
                           <el-input v-model.number="scope.row.number" size="small"
                               @change="(val)=>scope.row.number = isNaN(val)?null:val" clearable
                              @change="(val) => scope.row.number = isNaN(val) ? null : val" clearable
                              placeholder="请输入"></el-input>
                        </template>
                     </el-table-column>
                     <el-table-column prop="price" label="单价">
                     <el-table-column prop="price" label="单价" width="100">
                        <template slot-scope="scope">
                           <el-input v-model="scope.row.price" size="small" clearable placeholder="请输入"></el-input>
                        </template>
                     </el-table-column>
                     <el-table-column prop="username" label="联系人" width="150">
                        <template slot-scope="scope">
                           <el-input v-model="scope.row.username" size="small" clearable
                              placeholder="请输入"></el-input>
                        </template>
                     </el-table-column>
                     <el-table-column prop="phone" label="电话" width="200">
                        <template slot-scope="scope">
                           <el-input v-model="scope.row.phone" size="small" clearable placeholder="请输入"></el-input>
                        </template>
                     </el-table-column>
                     <el-table-column prop="address" label="地址" width="200">
                        <template slot-scope="scope">
                           <el-input v-model="scope.row.address" size="small" clearable
                              placeholder="请输入"></el-input>
                        </template>
                     </el-table-column>
                     <el-table-column prop="price" label="操作" width="65px">
                        <template slot-scope="scope">
                           <el-button type="text" @click.native.prevent="deleteRow(scope.$index, addData.saleMaterialList)">删除</el-button>
                           <el-button type="text"
                              @click.native.prevent="deleteRow(scope.$index, addData.saleMaterialList)">删除</el-button>
                        </template>
                     </el-table-column>
                  </el-table>
               </div>
            </div>
            <span slot="footer" class="dialog-footer">
               <el-button v-if="upDia==false" type="primary" @click="addSale">确 定</el-button>
               <el-button v-else-if="upDia==true" type="primary" @click="upSale">确 定</el-button>
               <el-button v-if="upDia == false" type="primary" @click="addSale">确 定</el-button>
               <el-button v-else-if="upDia == true" type="primary" @click="upSale">确 定</el-button>
               <el-button @click="addDia = false">取 消</el-button>
            </span>
         </el-dialog>
@@ -392,243 +412,309 @@
</template>
<script>
   export default {
      data() {
         return {
            search: {
               code: null,
               name: null,
               type: null,
               delTime: null
            },
            tableData: [],
            selects: '',
            currentPage: 1,
            countSize: 0,
            pageSize: 10,
            selectDia: false,
            oneData: null,
            addDia: false,
            addData: {
               orderNumber: null,
               code: null,
               name: null,
               proname: null,
               adress: null,
               username: null,
               delTime: null,
               orderName: null,
               phone: null,
               saleMaterialList: []
            },
            repeList: [],
            upDia: false
export default {
   data() {
      return {
         search: {
            code: null,
            name: null,
            type: null,
            delTime: null
         },
         tableData: [],
         selects: '',
         currentPage: 1,
         countSize: 0,
         pageSize: 10,
         selectDia: false,
         oneData: null,
         addDia: false,
         addData: {
            orderNumber: null,
            code: null,
            name: null,
            note: null,
            proname: null,
            adress: null,
            username: null,
            delTime: null,
            orderName: null,
            phone: null,
            saleMaterialList: []
         },
         repeList: [],
         isSync: false,
         upDia: false
      }
   },
   mounted() {
      this.selectRawInspectsList()
   },
   methods: {
      downloadFile(row) {
         let baseIp = "http://192.168.18.16:9999"
         this.axios.post(this.$api.url.saleDownload, {
            id: row.id
         }).then(res => {
            // console.log(res.data);
            // 循环遍历每个文件并创建下载链接
            for (let index = 0; index < 2; index++) {
               const element = res.data[0];
               // 创建一个链接元素
               var a = document.createElement('a');
               // 设置链接元素的href属性为文件的URL
               a.href = baseIp+element;
               // // 设置链接元素的download属性为文件名
               a.download = row.name+"附件"+(index+1);
               // 模拟点击链接以触发下载
               a.click();
               //
               a.remove()
            }
         })
      },
      closeDialog() {
         this.addData = {
            orderNumber: null,
            code: null,
            name: null,
            note: null,
            proname: null,
            adress: null,
            username: null,
            delTime: null,
            orderName: null,
            phone: null,
            saleMaterialList: []
         }
      },
      mounted() {
      handleSelectionChange(val) {
         this.selects = ''
         val.forEach((a, ai) => {
            this.selects += a.id
            if (ai != val.length - 1) {
               this.selects += ','
            }
         })
      },
      handleSizeChange(val) {
         this.pageSize = val
         this.selectRawInspectsList()
      },
      methods: {
         handleSelectionChange(val) {
            this.selects = ''
            val.forEach((a, ai)=>{
               this.selects += a.id
               if(ai!=val.length-1){
                  this.selects += ','
               }
            })
         },
         handleSizeChange(val) {
            this.pageSize = val
            this.selectRawInspectsList()
         },
         handleCurrentChange(val) {
            this.currentPage = val
            this.selectRawInspectsList()
         },
         selectRawInspectsList() {
            this.axios.get(this.$api.url.selectSaleList, {
               params: {
                  pageSize: this.currentPage,
                  countSize: this.pageSize,
                  delTime: this.search.delTime,
                  name: this.search.name,
                  type: this.search.type,
                  orderNumber: this.search.code
               }
            }).then(res => {
               this.tableData = res.data.row
               this.countSize = res.data.total
            })
         },
         clean() {
            this.selects = ''
            this.currentPage = 1
            this.countSize = 0
            this.pageSize = 10
            this.search = {
               formTime: null,
               createTime: null,
               insState: 2,
               judgeState: 2
      syncOrder() {
         this.isSync = true
         setTimeout(() => {
            this.$message({
               message: '同步假成功(◕ᴗ◕)!',
               type: 'success'
            });
            this.isSync = false
         }, 2000);
         return
         //调用同步接口
         this.axios.post(this.$api.url.synchronization).then(res => {
            if (res.code === '200') {
               this.isSync = false
               this.$message({
                  message: '同步成功!',
                  type: 'success'
               });
            }
            this.selectRawInspectsList()
         },
         changeShowDetail(ob) {
            this.selectDia = true
            this.axios.get(this.$api.url.selectSaleDatilById, {
               params: {
                  id: ob.id
               }
            }).then(res => {
               this.oneData = res.data
            })
         },
         addSaleMaterial() {
            this.addData.saleMaterialList.push({})
         },
         addSale() {
            for (var b = 0; b < this.addData.saleMaterialList.length; b++) {
               if (Object.keys(this.addData.saleMaterialList[b]).length == 0) {
                  this.addData.saleMaterialList.splice(b, 1)
                  b--
               } else {
                  for (var c in this.addData.saleMaterialList[b]) {
                     if (this.addData.saleMaterialList[b][c] == null || this.addData.saleMaterialList[b][c] == '' || Object
                        .keys(this.addData.saleMaterialList[b]).length != 5) {
                        this.$message.error('产品信息有必填项未填写')
                        return
                     }
                  }
               }
         })
      },
      handleCurrentChange(val) {
         this.currentPage = val
         this.selectRawInspectsList()
      },
      selectRawInspectsList() {
         this.axios.get(this.$api.url.selectSaleList, {
            params: {
               pageSize: this.currentPage,
               countSize: this.pageSize,
               delTime: this.search.delTime,
               name: this.search.name,
               type: this.search.type,
               orderNumber: this.search.code
            }
            for (var a in this.addData) {
               if (this.addData[a] == null || this.addData[a] == '') {
                  if (a == 'saleMaterialList') {
                     this.$message.error('产品信息不能为空')
                  } else {
                     this.$message.error('销售订单有必填项未填写')
                  }
                  return
               }
         }).then(res => {
            this.tableData = res.data.row
            this.countSize = res.data.total
         })
      },
      clean() {
         this.selects = ''
         this.currentPage = 1
         this.countSize = 0
         this.pageSize = 10
         this.search = {
            formTime: null,
            createTime: null,
            insState: 2,
            judgeState: 2,
            type: null
         }
         this.selectRawInspectsList()
      },
      changeShowDetail(ob) {
         this.selectDia = true
         this.axios.get(this.$api.url.selectSaleDatilById, {
            params: {
               id: ob.id
            }
            this.axios.post(this.$api.url.addSale, this.addData, {
               headers: {
                  'Content-Type': 'application/json'
               }
            }).then(res => {
               this.$message.success('添加成功')
               this.addDia = false
               this.selectRawInspectsList()
            })
         },
         openAddDia() {
            this.addDia = !(this.addDia)
            this.upDia = false
         },
         upRepe(index, i) {
            var data = this.repeList[index]
            if (data == undefined) {
               this.addData.saleMaterialList[i] = {}
         }).then(res => {
            this.oneData = res.data
         })
      },
      addSaleMaterial() {
         this.addData.saleMaterialList.push({})
      },
      addSale() {
         for (var b = 0; b < this.addData.saleMaterialList.length; b++) {
            if (Object.keys(this.addData.saleMaterialList[b]).length == 0) {
               this.addData.saleMaterialList.splice(b, 1)
               b--
            } else {
               this.addData.saleMaterialList[i].unit = data.unit
               this.addData.saleMaterialList[i].specifications = data.specifications
               for (var c in this.addData.saleMaterialList[b]) {
                  if (this.addData.saleMaterialList[b][c] == null || this.addData.saleMaterialList[b][c] == '' || Object
                     .keys(this.addData.saleMaterialList[b]).length != 5) {
                     this.$message.error('产品信息有必填项未填写')
                     return
                  }
               }
            }
         },
         saleCheck(ob) {
            this.$confirm(`订单${ob.row.code}的信息是否通过`, '销售订单审核', {
               distinguishCancelAndClose: true,
               confirmButtonText: '通过',
               cancelButtonText: '不通过'
         }
         for (var a in this.addData) {
            if (this.addData[a] == null || this.addData[a] == '') {
               if (a == 'saleMaterialList') {
                  this.$message.error('产品信息不能为空')
               } else {
                  this.$message.error('销售订单有必填项未填写')
               }
               return
            }
         }
         this.axios.post(this.$api.url.addSale, this.addData, {
            headers: {
               'Content-Type': 'application/json'
            }
         }).then(res => {
            this.$message.success('添加成功')
            this.addDia = false
            this.selectRawInspectsList()
         })
      },
      openAddDia() {
         this.addDia = !(this.addDia)
         this.upDia = false
      },
      upRepe(index, i) {
         var data = this.repeList[index]
         if (data == undefined) {
            this.addData.saleMaterialList[i] = {}
         } else {
            this.addData.saleMaterialList[i].unit = data.unit
            this.addData.saleMaterialList[i].specifications = data.specifications
         }
      },
      saleCheck(ob) {
         this.$confirm(`订单${ob.row.code}的信息是否通过`, '销售订单审核', {
            distinguishCancelAndClose: true,
            confirmButtonText: '通过',
            cancelButtonText: '不通过'
         }).then(res => {
            this.$axios.post(this.$api.url.saleCheck, {
               id: ob.row.id,
               type: 1
            }).then(res => {
               this.selectRawInspectsList()
               this.$parent.removeAllTab()
            })
         }).catch(e => {
            if (e == 'cancel') {
               this.$axios.post(this.$api.url.saleCheck, {
                  id: ob.row.id,
                  type: 1
                  type: 0
               }).then(res => {
                  this.selectRawInspectsList()
               })
            }).catch(e => {
               if (e == 'cancel') {
                  this.$axios.post(this.$api.url.saleCheck, {
                     id: ob.row.id,
                     type: 0
                  }).then(res => {
                     this.selectRawInspectsList()
                  })
            }
         })
      },
      openUpDia(index) {
         this.addDia = true
         this.upDia = true
         this.axios.get(this.$api.url.selectSaleDatilById, {
            params: {
               id: index
            }
         }).then(res => {
            this.addData = res.data
            this.addData.id = index
         })
      },
      upSale() {
         for (var b = 0; b < this.addData.saleMaterialList.length; b++) {
            if (Object.keys(this.addData.saleMaterialList[b]).length == 0) {
               this.addData.saleMaterialList.splice(b, 1)
               b--
            } else {
               for (var c in this.addData.saleMaterialList[b]) {
                  if (this.addData.saleMaterialList[b][c] == null || this.addData.saleMaterialList[b][c] == '' || Object
                     .keys(this.addData.saleMaterialList[b]).length != 9) {
                     this.$message.error('产品信息有必填项未填写')
                     return
                  }
               }
            })
         },
         openUpDia(index) {
            this.addDia = true
            this.upDia = true
            this.axios.get(this.$api.url.selectSaleDatilById, {
               params: {
                  id: index
               }
            }).then(res => {
               this.addData = res.data
               this.addData.id = index
            })
         },
         upSale() {
            for (var b = 0; b < this.addData.saleMaterialList.length; b++) {
               if (Object.keys(this.addData.saleMaterialList[b]).length == 0) {
                  this.addData.saleMaterialList.splice(b, 1)
                  b--
            }
         }
         for (var a in this.addData) {
            console.log(a);
            if ((this.addData[a] == null || this.addData[a] == '') && a != 'checkname' && a != 'checkTime' && a != 'type') {
               if (a == 'saleMaterialList') {
                  this.$message.error('产品信息不能为空')
               } else {
                  for (var c in this.addData.saleMaterialList[b]) {
                     if (this.addData.saleMaterialList[b][c] == null || this.addData.saleMaterialList[b][c] == '' || Object
                        .keys(this.addData.saleMaterialList[b]).length != 6) {
                        this.$message.error('产品信息有必填项未填写')
                        return
                     }
                  }
                  this.$message.error('销售订单有必填项未填写')
               }
            }
            for (var a in this.addData) {
               console.log(a);
               if ((this.addData[a] == null || this.addData[a] == '') && a!='checkname' && a!='checkTime' && a != 'type') {
                  if (a == 'saleMaterialList') {
                     this.$message.error('产品信息不能为空')
                  } else {
                     this.$message.error('销售订单有必填项未填写')
                  }
                  return
               }
            }
            this.axios.post(this.$api.url.updateSaleById, {
               id: this.addData.id,
               str: JSON.stringify(this.addData)
            }).then(res => {
               this.$message.success('编辑成功')
               this.addDia = false
               this.upDia = false
               this.selectRawInspectsList()
            })
         },
         deleteRow(index, rows) {
            rows.splice(index, 1);
         },
         delSale(index){
            this.axios.post(this.$api.url.delSale, {
               id: this.tableData[index].id,
            }).then(res => {
               this.$message.success('删除成功')
               this.tableData.splice(index, 1)
            })
         },
         delSales(){
            if(this.selects=='') {
               this.$message.warning('请选择一条数据删除')
               return
            }
            this.axios.post(this.$api.url.delAllSale,{
               ids: this.selects
            }).then(res=>{
               this.$message.success('删除成功')
               this.selectRawInspectsList()
            })
         }
         this.axios.post(this.$api.url.updateSaleById, {
            id: this.addData.id,
            str: JSON.stringify(this.addData)
         }).then(res => {
            this.$message.success('编辑成功')
            this.addDia = false
            this.upDia = false
            this.selectRawInspectsList()
         })
      },
      deleteRow(index, rows) {
         rows.splice(index, 1);
      },
      delSale(index) {
         this.axios.post(this.$api.url.delSale, {
            id: this.tableData[index].id,
         }).then(res => {
            this.$message.success('删除成功')
            this.tableData.splice(index, 1)
         })
      },
      delSales() {
         if (this.selects == '') {
            this.$message.warning('请选择一条数据删除')
            return
         }
         this.axios.post(this.$api.url.delAllSale, {
            ids: this.selects
         }).then(res => {
            this.$message.success('删除成功')
            this.selectRawInspectsList()
         })
      }
   }
}
</script>