<template>
  <div>
    <div class="borderless">
      <div class="customer-head">
        <div class="customer-back">
          <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left"
            @click="backToList">返回列表
          </el-button>
        </div>
        <div class="add-customer-btn">
          <!--<el-button type="info" icon="el-icon-printer" size="small" @click.stop="openReport()">报表打印-->
          <!--</el-button>-->
          <el-button type="primary" size="small"
            class="el-button--small-yh"  :disabled="!option.disabled" @click.stop="openEdit">编辑
          </el-button>
          <el-button type="primary" size="small" :disabled="option.disabled" @click="editCustomer">
            保存数据
          </el-button>
        </div>
      </div>
      <trade-card title="基础资料" style="margin-top: 60px" v-loading="loadingBtn">
        <avue-form ref="form" class="trading-form" v-model="form" :option="option">
          <template slot="corpId">
            <crop-select v-model="form.corpId" corpType="KH" :disabled="option.disabled"
              @getCorpData="getCorpData"></crop-select>
          </template>
        </avue-form>
      </trade-card>
      <trade-card title="设备信息" v-loading="loadingBtn">
        <avue-crud ref="crud" :option="optionList" :data="data" :table-loading="loading" @saveColumn="saveColumn"
          @resetColumn="resetColumn" :cell-style="cellStyle">
          <template slot="headerSerial">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"
              :disabled="option.disabled" circle></el-button>
          </template>

            <template slot="code" slot-scope="{ row, index }">
                <el-input v-if="row.$cellEdit" v-model="row.code"
                                 placeholder="请输入" size="small" :controls="false" style="width:100%;"></el-input>
                <span v-else>{{ row.code }}</span>
            </template>

            <template slot="remarks" slot-scope="{ row, index }">
                <el-input v-if="row.$cellEdit" v-model="row.remarks"
                          placeholder="请输入" size="small" :controls="false" style="width:100%;"></el-input>
                <span v-else>{{ row.remarks }}</span>
            </template>

            <template slot="exitDate" slot-scope="{ row, index }">
                <el-date-picker
                    v-if="row.$cellEdit"
                    v-model="row.exitDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    size="small"
                    placeholder="选择日期">
                </el-date-picker>
                <span v-else>{{ row.exitDate }}</span>
            </template>

            <template slot="maintenanceDate" slot-scope="{ row, index }">
                <el-date-picker
                    v-if="row.$cellEdit"
                    v-model="row.maintenanceDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    size="small"
                    placeholder="选择日期">
                </el-date-picker>
                <span v-else>{{ row.maintenanceDate }}</span>
            </template>

          <template slot="menu" slot-scope="{ row, index }">
              <el-button size="small" type="text" v-if="row.url" @click="imgurlfun(row)">信息码
              </el-button>
            <el-button size="small" type="text" :disabled="option.disabled" @click="rowCell(row, index)">{{
                row.$cellEdit ? "保存" : "修改"
            }}</el-button>
            <el-button size="small" type="text" :disabled="option.disabled" @click="rowDel(row, index)">删除
            </el-button>
          </template>
        </avue-crud>
      </trade-card>

      <!--<containerTitle title="上传附件"></containerTitle>-->
      <!--<c-upload v-loading="loadingBtn" typeUpload="CD"-->
      <!--  deleteUrl="/api/trade-purchase/woodHarvestingCloud/removeByFileId" :data="orderFilesList" display-->
      <!--  :enumerationValue="35.1" :disabled="detailData.status == 1"></c-upload>-->
      <dictbiz-dialog ref="dictbiz" title="添加单位" code="unit" parentId="1585962784498225154" @closed="getAllWorkDicts">
      </dictbiz-dialog>

      <report-dialog :switchDialog="switchDialog" :reportId="form.id" reportName="配件系统-采购单" @onClose="onClose()">
      </report-dialog>

        <!--图片查看-->
        <el-dialog
            title="信息码"
            :visible.sync="imgfalse"
            width="50%"
            append-to-body
            :before-close="imgfalseClose">
            <div>
                <img :src="imgtext" alt="">
            </div>
        </el-dialog>

        <el-dialog title="导入项目" append-to-body class="el-dialogDeep" :visible.sync="productVisible" width="80%"
                   :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" @close="closeGoods">
            <el-row>
                <el-col :span="5" style="height: 100%;overflow-y: auto">
                    <div>
                        <el-scrollbar>
                            <basic-container>
                                <avue-tree :option="productOption" :data="productDataGoods" @node-click="productnodeClick" />
                            </basic-container>
                        </el-scrollbar>
                    </div>
                </el-col>
                <el-col :span="19">
                    <basic-container>
                        <avue-crud ref="productCrud" :option="optionTwo" :data="productListShow" :page.sync="productPage"
                                   :search.sync="productSearch" @selection-change="productSelection" @search-change="goodsSearch"
                                   @current-change="productCurrent" @size-change="productSize"
                                   @refresh-change="productRefresh" @on-load="productonLoad" :table-loading="loading"
                                   @saveColumn="productSave" @resetColumn="productReset" :cell-style="cellStyle">
                            <template slot="menuLeft" slot-scope="{size}">
                                <el-tabs v-model="activeName" @tab-click="tabHandle">
                                    <el-tab-pane label="查询结果" name="searchList"></el-tab-pane>
                                    <el-tab-pane label="已选定数据" name="importStaging"></el-tab-pane>
                                </el-tabs>
                            </template>
                            <template slot-scope="scope" slot="menu">
                                <el-button type="text" icon="el-icon-edit" size="small"
                                           @click.stop="importStagList(scope.row, scope.index)" v-if="activeName == 'searchList'"
                                           :disabled="goodsListSave.findIndex(item => item.id == scope.row.id) !== -1">选择
                                </el-button>
                                <el-button type="text" icon="el-icon-delete" size="small"
                                           @click.stop="removeStagList(scope.row, scope.index)" v-else>移除
                                </el-button>
                            </template>
                        </avue-crud>
                    </basic-container>
                </el-col>
            </el-row>
            <span slot="footer" class="dialog-footer">
            <el-button @click="productVisible = false">取 消</el-button>
              <el-button type="primary" @click="importGoods">导入</el-button>
          </span>
        </el-dialog>
    </div>
  </div>
</template>

<script>
import { optionList } from "./js/optionList";
import { optionTwo } from "./js/optionListTwo";
import reportDialog from "@/components/report-dialog/main";
import { multiply, sum, subtract } from "@/util/calculate";
import { getList } from "@/api/basicData/product";
import {getList as GYSgetList} from "@/api/basicData/client";
import {getList as getListpp } from "@/api/tirePartsMall/basicData/brandPage";
import {
    projectGoodsSubmit
} from "@/api/basicData/ServiceLtems";
import {
    corpequipmentarchivesDetail,
    corpequipmentarchivesitemRemove,
    corpequipmentarchivesSubmit
} from "@/api/basicData/EquipmentArchives";
import { getGoodstype } from "@/api/basicData/product";
export default {
  name: "index",
  data() {
    return {
        // 图片的弹窗的开启
        imgfalse:false,
        imgtext:'',
      switchDialog: false,
      loadingBtn: false,
      addressTitle: null,
      form: {},
      form2: {
      },
      form3: {

      },
      data: [],

      option: {
        menuBtn: false,
        labelWidth: 90,
        disabled: false,
        column: [
          {
            label: "客户",
            prop: "corpId",

            rules: [
              {
                required: true,
                message: "",
                trigger: "blur"
              }
            ],
            span: 16,
          },
            {
                label: "电话",
                prop: "contactsTel",
                search: true,
                overHidden: true,
                span: 8,
                rules: [
                    {
                        required: true,
                        message: "",
                        trigger: "blur"
                    }
                ],
            },
            {
                label: "地址",
                prop: "address",
                overHidden: true,
                span: 8,
                rules: [
                    {
                        required: true,
                        message: "",
                        trigger: "blur"
                    }
                ],
            },
            {
                label: "联系人",
                prop: "contacts",
                search: true,
                overHidden: true,
                span: 8,
                rules: [
                    {
                        required: true,
                        message: "",
                        trigger: "blur"
                    }
                ],
            },


            {
                label: "编号",
                prop: "sysNo",
                search: true,
                overHidden: true,
                disabled:true,
                span: 8,
            },



            {
                label: "设备数量",
                prop: "equipmentNumber",
                disabled:true,
                overHidden: true,
                span: 4,
            },
            {
                label: "维修次数",
                prop: "maintenanceSecond",
                disabled:true,
                span: 4,
            },
          {
            label: "签约时间",
            prop: "signingDateStart",
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd 00:00:00",
            span: 8,
          },
          {
            label: "解约时间",
            prop: "signingDateEnd",
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd 00:00:00",
            span: 8,
          },
          {
            label: "备注",
            prop: "remarks",
            type: "textarea",
            minRows: 3,
            span: 16,
          }
        ]
      },
      option2: {
        menuBtn: false,
        labelWidth: 80,
        disabled: false,
        column: [
          {
            label: "税率",
            prop: "exchangeRate",
            type: "select",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=tax_rate",
            span: 4,
          },
          {
            label: "采购总数量",
            prop: "storageQuantity",
            disabled: true,
            span: 4,
          },
          {
            label: "成本",
            prop: "costAmount",
            disabled: true,
            span: 4,
          },
          {
            label: "毛利",
            prop: "grossProfit",
            disabled: true,
            span: 4,
          },
          {
            label: "订单金额",
            prop: "purchaseAmount",
            disabled: true,
            span: 4,
          },
          {
            label: "优惠金额",
            prop: "thisUsedProfit",
            span: 4,
          },
          {
            label: "合同金额",
            prop: "orderAmount",
            disabled: true,
            span: 8,
          },
          {
            label: "应付金额",
            prop: "balanceAmount",
            disabled: true,
            span: 8,
          },
          {
            label: "已付金额",
            prop: "settlmentAmount",
            disabled: true,
            span: 8,
          }
        ]
      },
      optiontabs1: {
        menuBtn: false,
        labelWidth: 90,
        column: [
          {
            label: "简称",
            prop: "a",
            type: "select",
            span: 24,
          },
          {
            label: "地址",
            prop: "b",
            type: "select",
            span: 24,
          },
          {
            label: "详细地址",
            prop: "c",
            span: 24,
          },
          {
            label: "邮编",
            prop: "d",
            span: 24,
          },
          {
            label: "备注",
            prop: "e",
            type: 'textarea',
            minRows: 3,
            span: 24,
          },
          {
            label: "地址智能识别",
            prop: "ad",
            placeholder: "例：上海市徐汇区枫林街道斜土路100号",
            type: "textarea",
            minRows: 3,
            span: 24,
          }
        ]
      },
      optiontabs2: {
        menuBtn: false,
        labelWidth: 80,
        column: [
          {
            label: "目的地",
            prop: "a",
            type: "select",
            rules: [
              {
                required: true,
                message: "",
                trigger: "blur"
              }
            ],
            span: 24,
          },
          {
            label: "物流公司",
            prop: "b",
            span: 24,
          },
          {
            label: "电话",
            prop: "c",
            span: 24,
          },
          {
            label: "地址",
            prop: "d",
            span: 24,
          },
          {
            label: "详细地址",
            prop: "e",
            span: 24,
          },
          {
            label: "邮编",
            prop: "f",
            span: 24,
          },
          {
            label: "备注",
            prop: "remarks",
            type: "textarea",
            minRows: 3,
            span: 24,
          },
          {
            label: "地址智能识别",
            prop: "g",
            type: "textarea",
            minRows: 3,
            span: 24,
          }
        ]
      },
        // 商品信息列表配置
      optionList: {},
        // 商品产品下拉数据
      goodsoptions: [],
        // 附件
      orderFilesList: [],

        // 导入项目的弹窗
        productVisible:false,
        // 产品左侧类别
        productOption: {
            addBtn: false,
            menu: false,
            size: "small",
            props: {
                labelText: "标题",
                label: "title",
                value: "value",
            }
        },
        // 产品左侧是数据
        productDataGoods:[],
        // 产品弹窗列表
        optionTwo:optionTwo,
        productPage:{
            pageSize: 20,
            currentPage: 1,
            total: 0,
            pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
        },
        productListShow:[],
        // 暂存的数据
        goodsListSave:[],
        // 产品弹窗tabs切换
        activeName:'searchList',
        // 弹窗选中的数据
        tableData:[],
        productSearch:{},

        loading:false,

    };
  },
  props: {
    detailData: {
      type: Object
    }
  },
  components: {
    reportDialog
  },
  async created() {
    this.optionList = optionList
      // 获取字典数据
      this.getAllWorkDicts()
      // 查看是否要id调用详情
    if (this.detailData.id) {
        this.option.disabled = true
      this.getDetail(this.detailData.id);
    }

    if (this.detailData.status == 1) {
      this.option.disabled = true;
      this.option2.disabled = true;
    }
      // 获取产品数据
    // getAllgoods().then(res => {
    //   this.goodsoptions = res.data.data
    // });
  },
  methods: {
      // 打印报表按钮事件
    openReport() {
      this.switchDialog = !this.switchDialog;
    },
    onClose(val) {
      this.switchDialog = val;
    },
      // 获取下拉字典
    getAllWorkDicts() {
        // 获取地址信息
        // this.findObject(this.option.column, "address").dicData = JSON.parse(localStorage.getItem('areaTypeTree'))
        getGoodstype().then(res => {
            this.findObject(this.optionList.column, "goodsTypeId").dicData = res.data.data;
        });
        // 获取品牌数据
        getListpp().then(res=>{
            this.findObject(this.optionList.column, "brand").dicData = res.data.data.records
            this.findObject(this.optionTwo.column, "brand").dicData = res.data.data.records
        })
        // 获取供应商厂家数据
        GYSgetList(1,20, {corpType:'GYS'}).then(res=>{
            this.findObject(this.optionTwo.column, "corpId").dicData = res.data.data.records
        })
    },
    cellStyle() {
      return "padding:0;height:40px;";
    },

    amountChange() {
      let val = 0
      this.data.forEach(e => {
        val = sum(val, e.amount)
        this.form.purchaseAmount = val
        this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
      })
    },
    // countChange(row) {
    //   row.amount = multiply(row.price, row.storageInQuantity)
    //   row.storageAmount = multiply(row.purchaseAmount, row.storageInQuantity)
    //   let val = 0
    //   this.data.forEach(e => {
    //     val = sum(val, e.amount)
    //     this.form.purchaseAmount = val
    //     this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
    //   })
    // },
      // 获取详情数据
    getDetail(id) {
      this.loadingBtn = true
      corpequipmentarchivesDetail({ id: id })
        .then(res => {
          this.form = res.data.data;
          this.data = res.data.data.corpEquipmentArchivesItemList;
          // this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];
        })
        .finally(() => {
          this.loadingBtn = false;
        });
    },
      // 客户下拉框
    getCorpData(row) {
      if (row) {
        this.form.corpName = row.cname
        this.form.corpTel = row.tel
      } else {
        this.form.corpName = null
        this.form.corpTel = null
      }
    },

    addRow() {
       this.$refs["form"].validate((valid, done) => {
          done();
          if (valid) {
             // this.data.push({ $cellEdit: true, storageId: this.form.storageId })
              this.tableData = []
              this.goodsListSave = []
              // 获取产品弹窗的左侧类型
              this.getGoodstypefun()
              this.productVisible = true
          } else {
             return false;
          }
       });
    },
    rowCell(row, index) {
      if (row.$cellEdit == true) {
        this.$set(row, "$cellEdit", false);
      } else {
        this.$set(row, "$cellEdit", true);
      }
    },
      // 删除
    rowDel(row, index) {
      this.$confirm("确定删除数据?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        if (row.id) {
          corpequipmentarchivesitemRemove({ids:row.id}).then(res => {
            this.$message({
              type: "success",
              message: "删除成功!"
            });
            this.data.splice(index, 1);
          });
        } else {
          this.$message({
            type: "success",
            message: "删除成功!"
          });
          this.data.splice(index, 1);
        }
        this.form.equipmentNumber = this.data.length
      });
    },
    //修改提交触发
    editCustomer() {
      this.$refs["form"].validate((valid, done) => {
        done();
        if (valid) {
          if (this.data.length == 0) {
            return this.$message.error('请添加一条商品信息');
          }
            // corpId	客户id
            // corpName	客户名称
            // sysNo	编号
            // equipmentNumber	设备数量
            // maintenance_second	维修次数
            // signingDate_start	签约开始时间
            // signingDate_end	签约结束时间
            // remarks	备注（收费指示）
            // updateUser	修改人
            // createUser	创建人
            // createTime	创建时间
            // updateTime	修改时间
            // status	状态（0 正常 1停用）
            // corpEquipmentArchivesItemList 设备明细

            // cname	设备名称
            // code	设备编码
            // brand	品牌
            // specs	规格尺寸
            // category	产品类别
            // categoryitem	产品分类
            // url	图片
            // goodsTypeId	商品类型id
            // exitDate	出场日期
            // repairReportDate	报修日期
            // brandId	品牌id
            let arr = this.data.map(item=>{
                return {
                    id:item.id?item.id:null,
                    cname:item.cname,
                    code:item.code,
                    brand:item.brand,
                    brandId:item.brandId,
                    specs:item.specs,
                    remarks:item.remarks,
                    goodsTypeId:item.goodsTypeId,
                    // goodsTypeName:item.goodsTypeName,
                    maintenanceSecond:item.maintenanceSecond?item.maintenanceSecond:0,
                    exitDate:item.exitDate?item.exitDate + ' 00:00:00':item.exitDate,
                    maintenanceDate:item.maintenanceDate?item.maintenanceDate + ' 00:00:00':item.maintenanceDate,
                    repairReportDate:item.repairReportDate,
                    url:item.url?item.url:null,
                    factoryId:item.factoryId?item.factoryId:null,
                    factoryName:item.factoryName?item.factoryName:null,
                    categoryitem:item.categoryitem?item.categoryitem:null
                }
            })
            const obj = {
                id:this.form.id?this.form.id:null,
                corpId:this.form.corpId,
                corpName:this.form.corpName,
                sysNo:null,
                equipmentNumber:this.data.length,
                maintenanceSecond:this.form.maintenanceSecond?this.form.maintenanceSecond:0,
                signingDateStart:this.form.signingDateStart,
                signingDateEnd:this.form.signingDateEnd,
                contacts:this.form.contacts,
                contactsTel:this.form.contactsTel,
                address:this.form.address,
                remarks:this.form.remarks,
                corpEquipmentArchivesItemList:arr
            }
            this.loadingBtn = true;
            // 附件
            // console.log(this.orderFilesList,522)
          corpequipmentarchivesSubmit({
              ...obj,
          })
            .then(res => {
              this.$message.success("保存成功");
              this.form = res.data.data;
              this.data = res.data.data.corpEquipmentArchivesItemList;
              // this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];
              this.detailData.status = 1
              this.option.disabled = true;
              this.option2.disabled = true;
              this.$refs.crud.refreshTable();
            })
            .finally(() => {
              this.loadingBtn = false;
            });
        } else {
          return false;
        }
      });
    },
      // 查看图片
      imgurlfun(row){
        this.imgfalse = true
          this.imgtext = row.url
      },
      imgfalseClose(){
        this.imgtext = ''
          this.imgfalse = false
      },
    async saveColumn() {
      const inSave = optionList
      if (inSave) {
        this.$nextTick(() => {
          this.$refs.crud.doLayout();
        });
        this.$message.success("保存成功");
        //关闭窗口
        this.$refs.crud.$refs.dialogColumn.columnBox = false;
      }
    },
    async resetColumn() {
      this.optionList = optionList;
      const inSave = optionList
      if (inSave) {
        this.$nextTick(() => {
          this.$refs.crud.doLayout();
        });
        this.getAllWorkDicts()
        this.$message.success("重置成功");
        this.$refs.crud.$refs.dialogColumn.columnBox = false;
      }
    },
    openEdit() {
      // this.detailData.status = 2
        this.option.disabled = false
      this.option = this.$options.data().option;
      this.option2 = this.$options.data().option2;
      this.$refs.crud.refreshTable();
    },
    //返回列表
    backToList() {
      this.$emit("goBack");
    },
      // ---------------------------------产品弹窗----------------------------------------
      // 产品弹窗导入
      importGoods(){
          if (this.goodsListSave.length > 0) {
              for (let item of this.goodsListSave) {
                  delete item.id
                  this.data.push({
                      $cellEdit: true,
                      storageId: this.form.storageId,
                      factoryId:item.corpId,
                      factoryName:item.corpName,
                      ...item
                  })
              }
          }else {
              for (let item of this.tableData) {
                  delete item.id
                  this.data.push({
                      $cellEdit: true,
                      storageId: this.form.storageId,
                      factoryId:item.corpId,
                      factoryName:item.corpName,
                      ...item
                  })
              }
          }
          console.log(this.data,802)
          this.form.equipmentNumber = this.data.length
          this.productVisible = false
      },
      // 产品选择左侧数据
      productnodeClick(data){
          this.productSearch.goodsTypeId = data.value
          this.productPage.currentPage = 1;
          this.productonLoad(this.productPage, this.productSearch);
      },
      // 产品弹窗的列表数据获取
      productonLoad(page, params = {}){
          let data = this.deepClone(Object.assign(params, this.productSearch));
          this.loading = true;
          getList(
              page.currentPage,
              page.pageSize,
              data
          ).then(res=>{
              // this.productListShow = res.data.data.records ? res.data.data.records : [];
              this.productListShow = res.data.data.records
              this.productPage.total = res.data.data.total;
              this.$nextTick(() => {
                  this.$refs.productCrud.doLayout();
              });
          }).finally(() => {
              this.loading = false;
          });
      },
      // 标签页切换
      tabHandle(data) {
          if (data.name == 'searchList') {
              this.productListShow = this.data;
              // this.productSearch.total = this.pageList.total
              this.productonLoad(this.productPage,this.productSearch);
          } else if (data.name == 'importStaging') {
              this.productListShow = this.goodsListSave;
              this.productSearch.total = 0
          }
      },
      // 获取产品左侧数据
      getGoodstypefun(){
          getGoodstype().then(res => {
              this.productDataGoods = res.data.data;
          });
      },
      // 弹窗选中的数据
      importStagList(row, index) {
          this.goodsListSave.push(row);
      },
      // 产品弹窗移除
      removeStagList(row, index) {
          this.goodsListSave.splice(row.$index, 1)
      },
      // 产品弹窗刷新触发
      productRefresh(){
          // this.treeDeptId = '';
          this.productPage.currentPage = 1;
          this.productonLoad(this.productPage,this.productSearch);
      },
      // 产品弹窗选择触发
      productSelection(list) {
          this.tableData = list
      },
      // 产品弹窗搜索按钮触发
      goodsSearch(params, done) {
          // this.treeDeptId = '';
          this.productonLoad(this.productPage,params);
          done()
      },
      // 产品弹窗分页
      productCurrent(val){
          this.productPage.currentPage = val;
      },
      productSize(val){
          this.productPage.currentPage = 1;
          this.productPage.pageSize = val;
      },
      // 产品弹窗的重置和保存
      productSave(){
          const inSave = optionTwo
          if (inSave) {
              this.$nextTick(() => {
                  this.$refs.productCrud.doLayout();
              });
              this.$message.success("保存成功");
              //关闭窗口
              this.$refs.productCrud.$refs.dialogColumn.columnBox = false;
          }
      },
      productReset(){
          this.optionTwo = optionTwo;
          const inSave = option
          if (inSave) {
              this.$nextTick(() => {
                  this.$refs.productCrud.doLayout();
              });
              this.getAllWorkDicts()
              this.$message.success("重置成功");
              this.$refs.productCrud.$refs.dialogColumn.columnBox = false;
          }
      },
      // 关闭弹窗的回调
      closeGoods() {
          this.productDataGoods = [];
          // this.treeDeptId = "";
          this.activeName = "searchList";
      },
  },
  watch: {
    // data: function (rows) {
    //   let val = 0
    //   rows.forEach(e => {
    //     val = sum(val, e.amount)
    //     this.form.purchaseAmount = val
    //     this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
    //   })
    // }
  }
};
</script>

<style lang="scss" scoped>
.trading-form ::v-deep .el-form-item {
  margin-bottom: 8px !important;
}

::v-deep .el-dialog__body {
  padding: 0px 20px 15px 20px;
}

::v-deep .el-form-item__error {
  display: none !important;
}

.img-form ::v-deep .el-form-item {
  height: 150px;
  line-height: 150px;
  margin-bottom: 8px !important;
}

.img-form ::v-deep .avue-upload__icon {
  font-size: 20px;
  width: 150px;
  height: 150px;
  line-height: 150px;
}

::v-deep .el-table .cell {
  padding: 0 2px !important;
}

::v-deep .avue-crud .el-table .el-form-item__label {
  left: -1px;
}

.addressTabs {
  display: flex;
  justify-content: center;

  span {
    width: 100px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
  }
}
</style>
