黎星凯
2024-05-08 b4adff68a07b783fc90da1c9370d8be5f383e700
admin-web/src/views/stock/transfer/transferApplication/index.vue
@@ -9,11 +9,11 @@
        <el-row style="margin-top: 15px">
          <el-col>
            <!--列表-->
            <div class="table-tool-bar" style="margin-bottom: 15px;">
              <my-button name="新增" @click="handleAdd" site="tools" size="medium" />
            <div class="table-tool-bar" style="margin-bottom: 15px">
              <my-button name="调拨申请" icon="el-icon-plus" @click="handleAdd" site="tools" size="medium" />
            </div>
            <div :style="{ 'overflow-y': 'auto', height: `${clientHeight - 320}px` }" v-loading="loading">
              <el-row class="card" :gutter="5">
            <div :style="{ 'overflow-y': 'auto', height: 'calc(100vh - 352px)' }" v-loading="loading">
              <el-row v-if="list.length" class="card" :gutter="5">
                <el-col v-for="(item, index) in list" :key="index" class="cm-item">
                  <el-card class="card-data">
                    <div class="card-container">
@@ -21,26 +21,76 @@
                        <div class="card-header-left">
                          <span>调拨单号:</span>
                          <span class="value">{{ item.businessFormCode }}</span>
                          <div v-if="item.states == 0 && item.procureDoc !=null" class="states states-warning">待出库</div>
                          <div v-if="item.states == 0 && item.procureDoc ==null" class="states states-warning">待提交</div>
                          <div v-if="item.states == 1" class="states states-warning">待接收</div>
                          <div v-if="item.states == 2" class="states states-success">已接收</div>
                          <div v-if="item.states == 4" class="states states-info">已撤销</div>
                        </div>
                        <div class="card-header-right">
                            <el-button site="form" type="success" size="mini" @click="handleExport(item)"
                              >导出调拨单</el-button
                            >
                          <el-button
                            v-if="item.states == 1"
                            site="form"
                            type="success"
                            size="mini"
                            @click="handleIncome(item)"
                            >入库</el-button
                          >
                          <el-button v-if="item.states == 0 && item.procureDoc ==null" site="form" type="primary" size="mini"
                                     @click="handleExport('transferExport',`调拨单-${item.businessFormCode}`, {id:item.id,type:0})"
                          >下载
                          </el-button
                          >
                          <el-button
                            v-if="item.states == 0 && item.procureDoc ==null"
                            site="form"
                            type="primary"
                            size="mini"
                            @click="handleUploadPage(item)"
                          >上传</el-button
                          >
                          <el-button
                            v-if="item.states == 0"
                            site="form"
                            type="danger"
                            size="mini"
                            @click="handleRevoke(item)"
                            >撤销</el-button
                          >
                          <el-button
                            v-if="item.states == 2"
                            site="form"
                            type="primary"
                            size="mini"
                            @click="handleExport('transferExport',`调拨入库单-${item.businessFormCode}`,{id:item.id,type: 1})"
                            >导出调拨入库单</el-button
                          >
                          <el-button name="查看详情" site="form" type="info" size="mini" @click="handleDetail(item)"
                            >查看详情</el-button
                          >
                        </div>
                      </div>
                      <div class="one-hed">
                        <div class="box"><span class="span-two">机构:</span>{{ item.agencyId }}</div>
                        <div class="box"><span class="span-two">操作人:</span>{{ item.buyerName }}</div>
                        <div class="box"><span class="span-two">接收机构:</span>{{ item.inAgencyName }}</div>
                        <div class="box"><span class="span-two">申请人:</span>{{ item.operatorName }}</div>
                        <div class="box">
                          <span class="span-two">调拨时间:</span>{{ item.procureTime | formatTime }}
                          <span class="span-two">申请调拨时间:</span>{{ item.createTime | formatTime }}
                        </div>
                        <div class="box"><span class="span-two">接收时间:</span>{{ item.inTime | formatTime }}</div>
                      </div>
                      <div class="one-hed">
                        <div class="box"><span class="span-two">调拨机构:</span>{{ item.outAgencyName }}</div>
                        <div class="box"><span class="span-two">调拨人:</span>{{ item.outOperatorName }}</div>
                        <div class="box">
                          <span class="span-two">调拨时间:</span>{{ item.outputTime | formatTime }}
                        </div>
                      </div>
                      <div class="card-end">
                        <div v-for="(just, index) in item.fromProcureTemplateInfoList" :key="index" class="item">
                          <div class="name">{{ just.goodsTemplateName }}</div>
                        <div v-for="(just, index) in item.fromTransferTemplateInfoList" :key="index" class="item">
                          <div class="name">{{ just.goodsName }}</div>
                          <div class="value-box">
                            <div class="value-box-item">
                              <span class="label">数量:</span>
@@ -54,6 +104,7 @@
                  </el-card>
                </el-col>
              </el-row>
              <el-empty v-else description="暂无数据"></el-empty>
            </div>
            <el-pagination
              :small="false"
@@ -69,34 +120,53 @@
        </el-row>
      </el-card>
    </el-container>
    <!-- 上传分发单文件-->
    <uploadPage
      v-if="uploadPageSetting.show"
      :setting="uploadPageSetting"
      ref="uploadRef"
      @close="uploadPageSetting.show = false"
      @search="refreshData"
    ></uploadPage>
    <!--添加/编辑弹窗-->
    <edit v-if="editSetting.show" :setting="editSetting" ref="editRef" @close="editSetting.show=false" @search="refreshData"></edit>
    <detail ref="detailRef"></detail>
    <my-import
      :import-setting="importSetting"
      :dialog-show="importSetting.dialogShow"
      :dialog-title="importSetting.dialogTitle"
    />
    <edit
      v-if="editSetting.show"
      :setting="editSetting"
      ref="editRef"
      @close="editSetting.show = false"
      @search="refreshData"
    ></edit>
    <detail
      v-if="detailSetting.show"
      :setting="detailSetting"
      @close="detailSetting.show = false"
      ref="detailRef"
    ></detail>
  </div>
</template>
<script>
import { procureList, procureDel, procureIncome } from '@/api/stock/procure/purchaseOrder';
import {transfeIncome, transferList, transferUpdStatus} from '@/api/stock/transfer';
import MyButton from '@/components/myButton/myButton';
import SettingIplatform from '@/utils/settingIplatform';
import myImport from '@/views/components/myImport';
import edit from './edit';
import detail from './detail';
import { getBaseUrl } from '@/utils/base';
import * as DateFormatter from '@/utils/DateFormatter';
import listPage from '@/views/mixins/listPage';
import transfer from '@/views/mixins/transfer';
import SettingIplatform from '@/utils/settingIplatform';
import uploadPage from './uploadPage';
import * as dataExport from "@/api/exportExcel";
import {downLoad} from "@/utils/base";
export default {
  name: 'index',
  components: { MyButton, myImport, edit, detail },
  mixins: [listPage, transfer],
  components: { MyButton, myImport, edit, detail,uploadPage },
  data() {
    return {
      loading: false,
      adddialog: false,
      list: [],
      // 搜索框
      items: [
@@ -108,27 +178,17 @@
          defaultValue: '',
        },
        {
          type: 'text',
          dataIndex: 'goodsTemplateName',
          type: 'select',
          dataIndex: 'goodsTemplateId',
          label: '物品名称',
          placeholder: '可模糊搜索',
          defaultValue: '',
        },
        {
          type: 'select',
          dataIndex: 'name',
          label: '调拨机构',
          placeholder: '请选择',
          placeholder: '请输入',
          defaultValue: '',
          options: [],
        },
        {
          type: 'select',
          dataIndex: 'name',
          label: '接收机构',
          placeholder: '请选择',
          defaultValue: '',
          options: [],
          optionsConfig: {
            label: 'goodsName',
            value: 'id',
            url: SettingIplatform.apiBaseURL + '/pc/base/goods/template/query/goodsTemplate',
          },
        },
        {
          type: 'select',
@@ -136,102 +196,52 @@
          label: '状态',
          placeholder: '请选择',
          defaultValue: '',
          options: [
            {
              label: '全部',
              value: '',
            },
            {
              label: '待调拨',
              value: '1',
            },
            {
              label: '已调拨',
              value: '2',
            },
          ],
          options: [],
        },
        {
          type: 'date-picker',
          dataIndex: 'val1',
          dataIndex: 'createTimeStart',
          label: '申请时间',
          defaultValue: '',
        },
        {
          type: 'date-picker',
          dataIndex: 'val2',
          dataIndex: 'createTimeEnd',
          label: '至',
          defaultValue: '',
        },
        {
          type: 'date-picker',
          dataIndex: 'val1',
          dataIndex: 'startTime',
          label: '接收时间',
          defaultValue: '',
        },
        {
          type: 'date-picker',
          dataIndex: 'val2',
          dataIndex: 'endTime',
          label: '至',
          defaultValue: '',
        },
      ],
      // 树数据
      treeDataList: [],
      // 搜索条件
      filterFrom: {
        tenantId: null,
        userName: null,
        userPhone: null,
        states: null,
      },
      // 导入
      importSetting: {
        dialogTitle: '导入',
        dialogShow: false,
        fileSettings: {
          data: {},
          uploadUrl: getBaseUrl() + '/pc/fin/sys/tenant/import', // 上传地址
          accept: '.xls', // 格式
          type: 'text', // 回显形式
          loading: false, // 导入效果
        },
        /* 模板下载 */
        templateSettings: {
          templateName: '导入模板.xls', // 名称
          templateUrl: SettingIplatform.apiBaseURL + '/pc/fin/sys/tenant/getImportTemplate', // 下载地址
        },
        onSuccess: null,
      },
      editSetting: {
        title: '',
        id: '',
        orgId: '',
        show: false,
      },
      pageNum: 1,
      pageSize: 10,
      total: 0,
      filterFrom: {},
    };
  },
  computed: {
    clientHeight() {
      return document.documentElement.clientHeight;
    },
  },
  filters: {
    formatTime(time) {
      if (!time) return;
      return DateFormatter.LongToDateTime(time);
    },
  },
  created() {
    this.filterFrom = {
      inAgencyId: this.userInfo.tenantId,
    };
    this.fetchData();
    this.items.map((v) => {
      if (v.label == '状态') {
        v.options = this.statesOptions;
      }
      return v;
    });
  },
  methods: {
    fetchData() {
      this.loading = true;
      procureList({
      transferList({
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        ...this.filterFrom,
@@ -239,86 +249,72 @@
        this.list = res.datas;
        this.total = res.totalRows;
        this.loading = false;
        console.log(this.list);
      });
    },
    //导入
    importOrg() {
      this.importSetting.dialogShow = true;
      this.importSetting.onSuccess = (response, callBack) => {
        if (response.code === 1) {
          this.$message.success(response.msg);
          this.search(1);
        } else {
          this.$message.warning(response.msg);
        }
        callBack();
      };
    },
    // 导出
    handleExport() {},
    // 新增
    handleAdd() {
      this.editSetting.id = null;
      this.editSetting.info = null;
      this.editSetting.title = '新增';
      this.editSetting.show = true;
    },
    // 编辑
    handleEdit(row) {
      this.editSetting.id = row.id;
      this.editSetting.info = null;
      this.editSetting.title = '编辑';
      this.editSetting.show = true;
    },
    // 详情
    handleDetail(row) {
      this.$refs.detailRef.open(row.id);
    },
    // 调拨
    // 入库
    handleIncome(row) {
      this.$confirm(`您确定 单号:${row.businessFormCode}  调拨吗?`, '调拨调拨')
        .then(function () {
          procureIncome({ id: row.id }).then((res) => {
            this.$message.success('调拨成功!');
            this.search();
          });
        })
        .catch(() => {});
      this.$confirm(`您确定 单号:${row.businessFormCode}  接收入库吗?`, '接收入库', {
        beforeClose: (action, instance, done) => {
          if (action == 'confirm') {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = '执行中...';
            transfeIncome({ id: row.id })
              .then((res) => {
                this.$message.success('接收入库成功!');
                done();
                instance.confirmButtonLoading = false;
                this.search(1);
              })
              .catch(() => {
                done();
              });
          } else {
            done();
          }
        },
      });
    },
    del(row) {
      this.$modal
        .confirm('是否确认删除调拨单号为"' + row.businessFormCode + '"的数据吗?')
        .then(function () {
          procureDel({ id: row.id }).then((res) => {});
        })
    // 撤销
    handleRevoke(row) {
      this.$confirm(`您确定撤销单号为"${row.businessFormCode}"  的数据吗?`, '撤销').then(() => {
        transferUpdStatus({ id: row.id }).then((res) => {
          this.$message.success('撤销成功!');
          this.search(1);
        });
      });
    },
    // 导入
    handleUploadPage(row) {
      this.uploadPageSetting.id = row.id;
      this.uploadPageSetting.title = '导入';
      this.uploadPageSetting.show = true;
    },
    /**
     * 导出调拨入库单
     * @param api
     * @param fileName
     * @param params
     */
    handleExport(api, fileName, params) {
      let loading = this.$loading({
        lock: true,
        text: '导出中,请稍候...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      });
      // 判断总条数是否大于最大支持条数
      dataExport[api](params)
        .then((res) => {
          this.$message.success('删除成功!');
          this.search();
          console.log(res)
          downLoad(res)
          this.$message.success('导出成功!');
          loading.close();
        })
        .catch(() => {});
    },
    // 分页
    handleSizeChange(pageSize) {
      this.pageSize = pageSize;
      this.search({ pageNum: 1 });
    },
    handleCurrentChange(pageNum) {
      this.myTable.paging.page.pageNum = pageNum;
      this.search({ pageNum: pageNum });
    },
    // 查询table列表
    search(pageNum) {
      this.fetchData();
    },
    refreshData() {
      this.pageNum = 1;
      this.pageSize = 10;
      this.search();
    },
    fifterForm(params) {
      this.filterFrom = Object.assign(this.filterFrom, params);
      this.search(1);
        .catch(() => {
          loading.close();
        });
    },
  },
};