| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 | <template>  <div>    <basic-container v-if="show">      <avue-crud        ref="crud"        :option="option"        :data="data"        :page.sync="page"        @search-change="searchChange"        :search.sync="search"        :table-loading="loading"        @on-load="onLoad"        @row-update="rowUpdate"        @refresh-change="refreshChange"        :cell-style="cellStyle">        <template slot-scope="scope" slot="lockingQuantity">          <span style="color: #409EFF;cursor: pointer" @click.stop="viewCell(scope.row,scope.index)">{{ scope.row.lockingQuantity }}</span><!--          <span v-if="Number(scope.row.lockingQuantity) > 0" style="color: #409EFF;cursor: pointer" @click.stop="viewCell(scope.row,scope.index)">{{ scope.row.lockingQuantity }}</span>--><!--          <span v-else>{{ scope.row.lockingQuantity }}</span>-->        </template>        <template slot="stockNameSearch">          <warehouse-select v-model="search.storageId" :configuration="configurationWarehouse" />        </template>        <template slot-scope="{row,index}" slot="menu">          <el-button            type="text"            size="small"            @click="rowCell(row,index)"          >{{ row.$cellEdit ? '保存' : '修改' }}          </el-button>          <el-button            type="text"            size="small"            v-if="!row.$cellEdit"            v-show="Number(row.lockingQuantity) <= 0"            @click="deletePrice(row,index)"          >删除          </el-button>        </template>        <template slot="menuLeft">          <el-button            type="primary"            size="small"            icon="el-icon-plus"            @click="excelBox = !excelBox"          >导入          </el-button>          <el-button            type="success"            icon="el-icon-download"            size="small"            @click="derivation()"          >下载模板          </el-button>          <el-button            type="info"            icon="el-icon-printer"            size="small"            :loading="exportLoading"            @click="derivation()"          >报表打印          </el-button>          <el-button            v-if="userInfo"            type="info"            icon="el-icon-printer"            size="small"            @click.stop="LockingQuantity"          >计算内贸锁定          </el-button>          <el-button            v-if="userInfo"            type="info"            icon="el-icon-printer"            size="small"            @click.stop="exportInventory"          >导出库存账          </el-button>        </template>      </avue-crud>      <el-dialog title="导入库存"                 append-to-body                 :visible.sync="excelBox"                 :close-on-click-modal="false"                 width="555px">        <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter"/>      </el-dialog>    </basic-container>    <report-dialog      :switchDialog="switchDialog"      :searchValue="statementData"      :reportName="'国内贸易-库存账'"      @onClose="onClose()"    ></report-dialog>  </div></template><script>import option from "./configuration/mainList.json"import {deleteTemplate,customerList,typeSave,LockingQuantity} from "@/api/basicData/inventoryAccount"import {getToken} from "@/util/auth";import { defaultDate } from "@/util/date";import reportDialog from "@/components/report-dialog/main";export default {  components:{    reportDialog  },  data() {    return {      data: [],      search:{},      userInfo:null,      // 仓库配置      configurationWarehouse: {        multipleChoices: false,        multiple: false,        collapseTags: false,        placeholder: "请点击右边按钮选择",        dicData: []      },      loading: false,      exportLoading:false,      switchDialog:false,      statementData: {},      excelForm: {},      excelOption: {        submitBtn: false,        emptyBtn: false,        column: [          {            label: '导入数据',            prop: 'excelFile',            type: 'upload',            drag: true,            loadText: '导入数据中,请稍等',            span: 24,            propsHttp: {              res: 'data'            },            tip: '请上传 .xls,.xlsx 标准格式文件',            action: "/api/blade-stock/stockgoods/import-price"          }        ]      },      excelBox: false,      option: option,      page: {        pageSize: 10,        pagerCount: 5,        total: 0,        pageSizes: [10,50,100,200,300]      },      show: true,      params: {        corpId: null,        itemId: null,        storageId:null      },    }  },  created() {    // this.search.createTime = defaultDate(1)    let i = 0;    this.option.column.forEach(item => {      if (item.search) i++    })    if (i % 3 !== 0){      const num = 3 - Number(i % 3)      this.option.searchMenuSpan = num * 8;      this.option.searchMenuPosition = "right";    }  },  mounted(){    this.userInfo = localStorage.getItem('saber-userInfo') && JSON.parse(localStorage.getItem('saber-userInfo')).content.role_name.split(',').includes('admin');  },  methods: {    cellStyle() {      return "padding:0;height:40px;";    },    derivation() {      this.$confirm("是否下载模板?", "提示", {        confirmButtonText: "确定",        cancelButtonText: "取消",        type: "warning"      }).then(() => {        window.open(`/api/blade-stock/stockgoods/export-template?${this.website.tokenHeader}=${getToken()}`);      });    },    uploadAfter(res, done, loading, column) {      console.log(res)      window.console.log(column);      this.excelBox = false;      this.page.currentPage = 1;      if (res) {        this.$message.warning(res)      } else {        this.$message.success('导入成功')      }      this.onLoad(this.page);      loading()      done();    },    rowCell(row, index) {      if (JSON.parse(localStorage.getItem("saber-userInfo")).content.account === "admin"){        this.findObject(this.option.column, "lockingQuantity").cell = true        this.$refs.crud.rowCell(row, index)      }else {        this.findObject(this.option.column, "lockingQuantity").cell = false        this.$refs.crud.rowCell(row, index)      }    },    deletePrice(row,index){      if (row.id){        this.$confirm("确定将选择数据删除?", {          confirmButtonText: "确定",          cancelButtonText: "取消",          type: "warning"        }).then(() => {          return deleteTemplate(row.id);        }).then(() => {          this.$message({            type: "success",            message: "操作成功!"          });          this.page.currentPage = 1;          this.onLoad(this.page);        })      }    },    //点击搜索按钮触发    searchChange(params, done) {      if (params.createTime) {        params.createStartTime = params.createTime[0]+ " " + "00:00:00"        params.createEndTime = params.createTime[1]+ " " + "23:59:59"        delete params.createTime;      }      this.page.currentPage = 1;      this.onLoad(this.page, params);      done()    },    onLoad(page, params = this.search) {      if (this.search.createTime && this.search.createTime.length > 0) {        params = {          ...params,          createStartTime: this.search.createTime[0]+ " " + "00:00:00",          createEndTime: this.search.createTime[1]+ " " + "23:59:59",        }        delete params.createTime;      }      let queryParams = Object.assign({}, params, {        size: page.pageSize,        current: page.currentPage,      })      this.loading = true;      customerList(queryParams).then(res => {        this.data = res.data.data.records        this.page.total = res.data.data.total      }).finally(() => {        this.loading = false;      })    },    rowUpdate(form, index, done) {      typeSave(form).then(res => {        this.$message({type: "success", message: form.id ? "修改成功!" : "新增成功!"});        // this.page.currentPage = 1;        // this.onLoad(this.page);        //成功关闭此页面回到列表页        // this.backToList()      })      done()    },    // 查看    viewCell(row, index) {      if (this.$store.getters.domStockDetail) {        this.$alert("明细已存在,请保存关闭明细再进行操作", "温馨提示", {          confirmButtonText: "确定",          type: "warning",          callback: action => {            console.log(action);          }        });      } else {        this.params.corpId = row.corpId        this.params.itemId = row.goodsId        this.params.storageId = row.storageId        this.$router.$avueRouter.closeTag("/businessManagement/inventoryAccount/detail");        this.$router.push({          path: "/businessManagement/inventoryAccount/detail",          query: {            corpId: row.corpId,            itemId: row.goodsId,            storageId:row.storageId          },        });      }      // this.show = false;    },    statement() {      this.statementData = {...this.search};      if (this.statementData.createTime && this.statementData.createTime.length > 0) {        this.statementData.createStartTime = this.statementData.createTime[0]+ " " + "00:00:00"        this.statementData.createEndTime = this.statementData.createTime[1]+ " " + "23:59:59"        delete this.statementData.createTime;      }      this.switchDialog = !this.switchDialog;    },    onClose(val) {      this.switchDialog = val;    },    //列表刷新触发    refreshChange() {      this.data.forEach(item => {        this.$refs.crud.toggleRowExpansion(item, false)      })      this.page.currentPage = 1;      this.onLoad(this.page,this.search);    },    //计算内贸锁定    LockingQuantity() {      this.loading = true;      LockingQuantity().finally(() => {        this.loading = false;      })    },    //导出库存账    exportInventory() {      let params = { ...this.search }      console.log(params);      let queryParams = Object.assign({}, params);        if(params.storageId !== null && params.storageId !== undefined){          queryParams.storageId = params.storageId;        }else{          delete queryParams.storageId        }      console.log(queryParams);      this.$confirm('是否导出库存账?', '提示', {        confirmButtonText: '确定',        cancelButtonText: '取消',        type: 'warning'      }).then(() => {        const routeData = this.$router.resolve({          path: '/api/blade-stock/stockgoods/export',      //跳转目标窗口的地址          query: {            'Blade-Auth': getToken(),            ...queryParams    //括号内是要传递给新窗口的参数          }        })        window.open(routeData.href.slice(1, routeData.href.length));      }).catch(() => {        this.$message({          type: 'info',          message: '已取消' //        });      })    },  }}</script>
 |