admin-web/src/views/stock/procure/purchaseOrder/index.vue
@@ -1,5 +1,5 @@
<template>
  <div class="app-container">
  <div class="app-container stock-container">
    <el-container>
      <el-card class="box-card" style="width: 100%" shadow="never">
        <!--搜索条件-->
@@ -9,67 +9,77 @@
        <el-row style="margin-top: 15px">
          <el-col>
            <!--列表-->
            <my-button name="新增" @click="addtable" site="tools" size="medium" />
            <my-button name="导入" @click="importSetting.dialogShow = true" site="tools" size="medium" />
            <div :style="{ 'overflow-y': 'auto', height: `${clientHeight - 320}px` }" v-loading="loading">
              <el-row 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">
                      <div class="card-header">
                        <div class="card-header-left">
                          <span>入库单号:</span>
                          <span class="value">{{ item.businessFormCode }}</span>
                          <div class="states" :class="item.states==1?'':'states-income'">{{ item.states == 1 ? '待入库' : '已入库' }}</div>
                        </div>
                        <div class="card-header-right">
                          <template v-if="item.states == 1">
                            <el-button name="编辑" site="form" type="success" size="mini" @click="handleEdit(item)"
                              >编辑</el-button
                            >
                            <el-button name="入库" site="form" type="primary" size="mini" @click="handleIncome(item)"
                              >入库</el-button
                            >
                            <el-button name="删除" site="form" type="danger" size="mini" @click="del(item)"
                              >删除</el-button
                            >
                          </template>
                          <template v-if="item.states != 1">
                            <el-button site="form" type="success" size="mini" @click="handleExport(item)"
                              >导出入库单</el-button
                            >
                          </template>
                          <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.procureTime }}</div>
                        <div class="box"><span class="span-two">入库时间:</span>{{ item.procureTime }}</div>
                      </div>
                      <div class="card-end">
                        <div v-for="(just, index) in item.models" :key="index" class="item">
                          <div class="name">{{ just.baseGoodsModelsId }}</div>
                          <div class="value-box">
                            <div class="value-box-item">
                              <span class="label">数量:</span>
                              <span class="value">{{ just.counts }}</span>
            <div class="table-tool-bar" style="margin-bottom: 15px">
<!--              <my-button name="新增"  check-permission="procure:order:add" @click="handleAdd" site="tools" size="medium" />-->
              <my-button name="新增" @click="handleAdd" site="tools" size="medium" />
              <my-button name="导入" @click="openImport()" site="tools" size="medium" />
            </div>
            <div v-loading="loading" style="margin-bottom: 15px">
              <div :style="{ 'overflow-y': 'auto', height: 'calc(100vh - 352px)' }">
                <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">
                        <div class="card-header">
                          <div class="card-header-left">
                            <span>入库单号:</span>
                            <span class="value">{{ item.businessFormCode }}</span>
                            <div class="states" :class="item.states == 1 ? '' : 'states-success'">
                              {{ item.states == 1 ? '待入库' : '已入库' }}
                            </div>
                            <div class="value-box-item">
                              <span class="label">金额:</span>
                              <span class="value">{{ just.price }}</span>
                          </div>
                          <div class="card-header-right">
                            <template v-if="item.states == 1">
                              <el-button name="编辑" site="form" type="success" size="mini" @click="handleEdit(item)"
                              >编辑</el-button
                              >
                              <el-button name="入库" site="form" type="primary" size="mini" @click="handleIncome(item)"
                              >入库</el-button
                              >
                              <el-button name="删除" site="form" type="danger" size="mini" @click="del(item)"
                              >删除</el-button
                              >
                            </template>
                            <template v-if="item.states != 1">
                              <el-button site="form" type="success" size="mini" @click="handleExport('procureExport',`采购入库单-${item.businessFormCode}`,{id:item.id})"
                              >导出入库单</el-button
                              >
                            </template>
                            <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.agencyName }}</div>
                          <div class="box"><span class="span-two">操作人:</span>{{ item.buyerName }}</div>
                          <div class="box">
                            <span class="span-two">采购时间:</span>{{ item.procureTime | formatTime }}
                          </div>
                          <div class="box">
                            <span class="span-two">入库时间:</span>{{ item.incomeTime | 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 class="value-box">
                              <div class="value-box-item">
                                <span class="label">数量:</span>
                                <span class="value">{{ just.count }}</span>
                                <span class="unit">{{ just.unit }}</span>
                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </el-card>
                </el-col>
              </el-row>
                    </el-card>
                  </el-col>
                </el-row>
                <el-empty v-else description="暂无数据"></el-empty>
              </div>
            </div>
            <el-pagination
              :small="false"
              :current-page="pageNum"
@@ -85,8 +95,19 @@
      </el-card>
    </el-container>
    <!--添加/编辑弹窗-->
    <edit ref="editRef"></edit>
    <detail ref="detailRef"></detail>
    <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>
    <my-import
      :import-setting="importSetting"
      :dialog-show="importSetting.dialogShow"
@@ -96,32 +117,24 @@
</template>
<script>
import { procureList, procureDel, procureIncome } from '@/api/stock/procure/purchaseOrder';
import {procureDel, procureIncome, procureList} from '@/api/stock/procure/purchaseOrder';
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 {getBaseUrl} from '@/utils/base';
import listPage from '@/views/mixins/listPage';
export default {
  name: 'index',
  mixins: [listPage],
  components: { MyButton, myImport, edit, detail },
  data() {
    return {
      loading: false,
      adddialog: false,
      list: [],
      formData: {
        tableData: [
          {
            projectName: '555',
          },
          {
            projectName: '444',
          },
        ],
      },
      // 搜索框
      items: [
        {
@@ -131,24 +144,39 @@
          placeholder: '请输入',
          defaultValue: '',
        },
        // {
        //   type: 'text',
        //   dataIndex: 'goodsTemplateName',
        //   label: '物品名称',
        //   placeholder: '可模糊搜索',
        //   defaultValue: '',
        // },
        {
          type: 'text',
          dataIndex: 'goodsTemplateName',
          label: '物品名称',
          placeholder: '可模糊搜索',
          defaultValue: '',
        },
        {
          type: 'select',
          dataIndex: 'name',
          type: 'cascader',
          dataIndex: 'agencyId',
          label: '机构',
          placeholder: '请选择',
          optionsConfig: { url: '/pc/fin/sys/tenant/select/tree_fin_tenant', props: null },
          cascader: [{key:'goodsTemplateId',queryKey: 'agencyId'}],
          defaultValue: '',
          options: [],
        },
        {
          type: 'select',
          dataIndex: 'goodsTemplateId',
          label: '物品名称',
          placeholder: '请输入',
          defaultValue: '',
          options: [],
          optionsConfig: {
            label: 'goodsName',
            value: 'id',
            url: SettingIplatform.apiBaseURL + '/pc/base/goods/template/query/goodsTemplate',
          },
        },
        {
          type: 'text',
          dataIndex: 'buyerName',
          dataIndex: 'createName',
          label: '创建人',
          placeholder: '请输入',
          defaultValue: '',
@@ -176,62 +204,41 @@
        },
        {
          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', // 上传地址
          uploadUrl: getBaseUrl() + '/pc/whForm/procure/import', // 上传地址
          accept: '.xls', // 格式
          type: 'text', // 回显形式
          loading: false, // 导入效果
          loading: true, // 导入效果
        },
        /* 模板下载 */
        templateSettings: {
          templateName: '导入模板.xls', // 名称
          templateUrl: SettingIplatform.apiBaseURL + '/pc/fin/sys/tenant/getImportTemplate', // 下载地址
          templateUrl: SettingIplatform.apiBaseURL + '/pc/fin/sys/tenant/getImportTemplate?type=procure', // 下载地址
        },
        onSuccess: null,
      },
      editSetting: {
        title: '',
        id: '',
        orgId: '',
        show: false,
      },
      pageNum: 1,
      pageSize: 10,
      total: 0,
    };
  },
  computed: {
    clientHeight() {
      return document.documentElement.clientHeight;
    },
  },
  created() {
    this.fetchData();
  created(){
    this.fetchData()
  },
  methods: {
    fetchData() {
@@ -244,9 +251,9 @@
        this.list = res.datas;
        this.total = res.totalRows;
        this.loading = false;
        console.log(this.list);
      });
    },
    //导入
    importOrg() {
      this.importSetting.dialogShow = true;
@@ -260,183 +267,47 @@
        callBack();
      };
    },
    // 导出
    handleExport() {
    },
    // 新增
    addtable() {
      this.$refs.editRef.open();
    },
    // 编辑
    handleEdit(row) {
      this.$refs.editRef.open(row.id);
    },
    // 详情
    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('入库成功!');
          });
        })
        .then((res) => {
          this.search();
        })
        .catch(() => {});
      this.$confirm(`您确定 单号:${row.businessFormCode}  入库吗?`, '采购入库', {
        beforeClose: (action, instance, done) => {
          if (action == 'confirm') {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = '执行中...';
            procureIncome({ id: row.id })
              .then((res) => {
                this.$message.success('入库成功!');
                done();
                instance.confirmButtonLoading = false;
                this.search();
              })
              .catch(() => {
                done();
              });
          } else {
            done();
          }
        },
      });
    },
    del(row) {
      this.$modal
        .confirm('是否确认删除入库单号为"' + row.businessFormCode + '"的数据吗?')
        .then(function () {
          procureDel({ id: row.id }).then((res) => {});
        })
        .then((res) => {
          this.$message.success('删除成功!');
          this.search();
        })
        .catch(() => {});
      this.$modal.confirm('是否确认删除入库单号为"' + row.businessFormCode + '"的数据吗?').then(() => {
        procureDel({ id: row.id })
          .then((res) => {
            this.$message.success('删除成功!');
            this.search();
          })
          .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();
    },
    fifterForm(params) {
      this.filterFrom = Object.assign(this.filterFrom, params);
      this.search(1);
    },
    openImport(){
      this.importOrg();
    }
  },
};
</script>
<style scoped lang="scss">
.ml-20 {
  margin-left: 20px;
}
.card {
  display: flex;
  flex-wrap: wrap;
  margin: 0px !important;
  .cm-item {
    width: 100%;
  }
  .cm-item ::v-deep .el-card__body {
    padding-bottom: 5px;
  }
}
.card-data {
  position: relative;
  margin-top: 8px;
  .card-container {
    .card-header {
      height: 48px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: #f3f9fe;
      padding: 0 32px 0 15px;
      box-sizing: border-box;
    }
    .card-header-left {
      display: flex;
      align-items: center;
      color: #999999;
      font-family: 'Microsoft YaHei UI';
      font-size: 18px;
      font-weight: 700;
      .value {
        color: #3d3d3d;
      }
      .states {
        width: 54px;
        height: 22px;
        line-height: 22px;
        text-align: center;
        border-radius: 4px;
        border: 1px solid #f9675b99;
        background: #f9675b1a;
        font-family: 'Microsoft YaHei';
        color: #f9675b;
        font-size: 13px;
        font-style: normal;
        font-weight: 400;
        margin-left: 8px;
      }
      .states-income {
        border: 1px solid #39ad6199;
        background: #39ad610f;
        color: #39ad61;
      }
    }
    .one-hed {
      margin-top: 15px;
      padding: 0 32px 0 15px;
      box-sizing: border-box;
      .box {
        display: inline-block;
        margin-right: 20px;
      }
      .span-two {
        color: #83919e;
        font-size: 14px;
      }
    }
    .card-end {
      font-size: 14px;
      color: #3d3d3d;
      margin-top: 15px;
      display: flex;
      flex-wrap: wrap;
      font-family: 'Microsoft YaHei UI';
      padding: 0 16px;
      box-sizing: border-box;
      .item {
        width: 379px;
        height: 60px;
        padding: 8px 12px 9px 12px;
        box-sizing: border-box;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
        background: #f9f9f9;
        margin-right: 15px;
        margin-bottom: 15px;
        &:last-child {
          margin-right: 0;
        }
        .name {
          height: 22px;
          line-height: 22px;
        }
        .value-box {
          display: flex;
          .value-box-item {
            margin-right: 20px;
            .label {
              color: #99999999;
              line-height: 22px;
            }
            .value {
              color: #ff3131;
            }
          }
        }
      }
    }
  }
}
@import url(../../index.scss);
</style>