石广澎
2024-01-05 b2429057ae17e9f5b357435b0bff5f6cc0040b69
admin-web/src/views/stock/ledger/inventoryQuery/index.vue
@@ -13,149 +13,139 @@
              <my-table-v2 ref="myTable" :filter="filterFrom" :table="table"/>
            </el-col>
          </el-row>
          <!--添加/编辑弹窗-->
          <edit v-if="editSetting.show" :setting="editSetting" @close="editSetting.show = false" @search="search"/>
        </el-card>
      </el-container>
    </el-container>
    <my-import
      :import-setting="importSetting"
      :dialog-show="importSetting.dialogShow"
      :dialog-title="importSetting.dialogTitle"
    />
  </div>
</template>
<script>
import MyTableV2 from "@/components/myTable/myTableV2";
import MyButton from "@/components/myButton/myButton";
import MyTableV2 from '@/components/myTable/myTableV2';
import MyButton from '@/components/myButton/myButton';
import SettingIplatform from '@/utils/settingIplatform';
import edit from './edit'
import * as finsystenant from '@/api/baseSetting/finsystenant'
import myImport from '@/views/components/myImport'
import {getBaseUrl} from '@/utils/base';
import {doExport} from '@/api/stock/ledger';
export default {
  name: "index",
  components: {MyButton, MyTableV2, edit, myImport},
  name: 'index',
  components: {MyButton, MyTableV2},
  data() {
    return {
      // 搜索框
      items: [
        {
          type: 'text',
          dataIndex: 'name',
          label: '单号',
          placeholder: '请输入',
          defaultValue: ''
          type: 'cascader',
          dataIndex: 'agencyId',
          label: '机构',
          placeholder: '请选择',
          defaultValue: '',
          options: [],
          cascader: [{key: 'warehouseId', queryKey: 'agencyId'}, {key: 'goodsTemplateId', queryKey: 'agencyId'}],
          optionsConfig: {url: '/pc/fin/sys/tenant/select/tree_fin_tenant', props: null},
        },
        {
          type: 'select',
          dataIndex: 'status',
          label: '类型',
          dataIndex: 'warehouseId',
          label: '仓库',
          placeholder: '请选择',
          defaultValue: '1',
          options: [
            {
              label: '启用',
              value: '1'
            },
            {
              label: '禁用',
              value: '0'
            }
          ]
          defaultValue: '',
          options: [],
          optionsConfig: {
            label: 'warehouseName',
            value: 'id',
            url: SettingIplatform.apiBaseURL + '/pc/base/warehouse/select/tenant_warehouse'
          },
        },
        {
          type: 'text',
          dataIndex: 'name',
          type: 'cascader',
          dataIndex: 'categoryId',
          label: '分类',
          placeholder: '请选择',
          defaultValue: '',
          options: [],
          optionsConfig: {
            label: 'label',
            value: 'id',
            url: SettingIplatform.apiBaseURL + '/pc/base/category/select/tree',
            props: {checkStrictly: false, emitPath: false, value: 'id'}
          },
          cascader: [{key:'goodsTemplateId',queryKey: 'categoryId'}],
        },
        {
          type: 'select',
          dataIndex: 'goodsTemplateId',
          label: '物品名称',
          placeholder: '请输入',
          defaultValue: ''
          defaultValue: '',
          options: [],
          cascader: [{key: 'categoryId', queryKey: 'goodsTemplatesId'}],
          optionsConfig: {
            label: 'goodsName',
            value: 'id',
            url: SettingIplatform.apiBaseURL + '/pc/base/goods/template/query/goodsTemplate',
          },
        },
        {
          type: 'text',
          dataIndex: 'name',
          label: '创建人',
          placeholder: '请输入',
          defaultValue: ''
          type: 'select',
          dataIndex: 'costType',
          label: '类别',
          placeholder: '请选择',
          defaultValue: '',
          options: [{
            label: 'A',
            value: '1'
          }, {
            label: 'B',
            value: '2'
          }, {
            label: 'C',
            value: '3'
          }],
        },
      ],
      // 树数据
      treeDataList: [],
      // 搜索条件
      filterFrom: {
        tenantId: null,
        userName: null,
        userPhone: null,
        status: 1
      },
      // 导入
      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,
        warehouseType: 0
      },
      // 表格数据
      table: {
        showIndex: true, // 是否显示序号
        expand: false, // 是否显示详情数据
        url: SettingIplatform.apiBaseURL + '/pc/fin/sys/tenant/select/list', // 请求地址
        url: SettingIplatform.apiBaseURL + '/pc/fin/warehouse/ledger/getList', // 请求地址
        // 工具条
        tools: {
          columnsCtrl: {// 列控制按钮
            show: false
          columnsCtrl: {
            // 列控制按钮
            show: false,
          },
          generalExport: {// 通用导出按钮
            show: false
          generalExport: {
            // 通用导出按钮
            show: false,
          },
          // 自定义工具条按钮
          custom: [
          ]
        },
        // 列信息
        columns: [
          {title: '类型', field: 'name', align: 'left',},
          {title: '单号', field: 'code', align: 'center'},
          {title: '物品名称', field: 'lv', align: 'center', },
          {title: '规格型号', field: 'lv', align: 'center', },
          {title: '出入库数量', field: 'summary', align: 'left',},
          {title: '金额', field: 'summary', align: 'left',},
          {title: '所属机构', field: 'summary', align: 'left',},
          {title: '创建人', field: 'summary', align: 'left',},
          {title: '操作时间', field: 'summary', align: 'left',},
        ],
        // 操作信息
        operation: {
          show: true, // 显示操作列
          width: '150', // 列宽
          attr: [
            {
              title: '详情',
              events: (row) => {
                this.showAudit(row);
              name: '导出',
              icon: 'el-icon-download',
              click: () => {
                this.handleExport();
              },
            },
          ],
        },
        // 列信息
        columns: [
          {title: '机构', field: 'agencyName', align: 'left', minWidth: 130},
          {title: '仓库', field: 'warehouseName', align: 'left', minWidth: 130},
          {title: '分类', field: 'categoryName', align: 'left', minWidth: 130},
          {title: '所属类别', field: 'costType', align: 'center', width: 80},
          {title: '物品名称', field: 'goodsTemplateName', align: 'left', minWidth: 140},
          {title: '规格型号', field: 'baseGoodsModelsName', align: 'left', minWidth: 130},
          {title: '单位', field: 'unit', align: 'center', width: 80},
          {title: '当前库存', field: 'kucun', align: 'center'},
        ],
        paging: {
          show: true, // 显示分页
          // 分页信息
@@ -163,118 +153,64 @@
            small: false,
            pageNum: 1,
            pageSize: 10,
            total: 0
          }
        }
            total: 0,
          },
        },
      },
    }
    };
  },
  created() {
    // 获取机构树
    this.initTreeData()
  },
  methods: {
    //导入
    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)
    // 导出
    handleExport() {
      let loading = this.$loading({
        lock: true,
        text: '导出中,请稍候...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)',
      });
      // 判断总条数是否大于最大支持条数
      doExport({...this.filterFrom})
          .then((res) => {
            const blob = new Blob([res], {type: 'application/vnd.ms-excel'});
            const fileName = `库存查询.xls`;
            if ('download' in document.createElement('a')) {
              // 非IE下载
              const elink = document.createElement('a');
              elink.download = fileName;
              elink.style.display = 'none';
              elink.href = URL.createObjectURL(blob);
              document.body.appendChild(elink);
              elink.click();
              URL.revokeObjectURL(elink.href);
              document.body.removeChild(elink);
            } else {
              // IE10+下载
              navigator.msSaveBlob(blob, fileName);
            }
            callBack()
        }
    },
    // 左侧树初始化
    initTreeData() {
      finsystenant.getTree().then(res => {
        const content = res || []
        this.treeDataList.splice(0, this.treeDataList.length)
        this.treeDataList = content
        if (content.length > 0) {
          this.importSetting.fileSettings.data = {pid: content[0].id}
        }
      })
    },
    updState(row) {
      let vm = this
      let text = row.status == 0 ? "启用" : "禁用";
      vm.$modal.confirm('确认要' + text + '"' + row.name + '"吗?').then(function () {
        let params = Object.assign({}, row)
        params.status = row.status == 1 ? 0 : 1
        finsystenant.edit(params).then(res => {
          if (res) {
            row.status = row.status === 1 ? 0 : 1
            vm.$modal.msgSuccess(text + "成功");
            vm.search()
          }
        })
      })
    },
    del(row) {
      this.$modal
        .confirm('是否确认删除名称为"' + row.name + '"的机构吗?')
        .then(function () {
          finsystenant.del({id: row.id}).then((res) => {
            this.$message.success('导出成功!');
            loading.close();
          })
          .catch(() => {
            loading.close();
          });
        })
        .then((res) => {
          this.$message.success('删除成功!');
          this.search()
        })
        .catch(() => {
        });
    },
    showAdd() {
      // if (!this.editSetting.orgId) {
      //   this.$message.warning('请先选择左侧机构')
      // } else {
        this.editSetting.id = null;
        this.editSetting.info = null;
        this.editSetting.title = '新增';
        this.editSetting.show = true;
      // }
    },
    showAudit(row) {
      this.editSetting.id = row.id;
      this.editSetting.info = JSON.stringify(row);
      this.editSetting.title = '编辑';
      this.editSetting.show = true;
    },
    nodeClick(param) {
      param = param || {}
      this.p = Object.assign({}, {
        id: param.id,
        name: param.name
      })
      if (this.p.id != undefined && this.p.id != null) {
        this.filterFrom.tenantId = this.p.id
        this.editSetting.orgId = this.p.id
      } else {
        this.filterFrom.tenantId = null
        this.editSetting.orgId = null
      }
      this.importSetting.fileSettings.data = {pid: param.id}
      this.search(1)
    },
    // 查询table列表
    search(pageNum) {
      if (pageNum != undefined) {
        this.$refs.myTable.search(pageNum)
        this.$refs.myTable.search({pageNum});
      } else {
        this.$refs.myTable.search()
        this.$refs.myTable.search();
      }
    },
    fifterForm(params) {
      this.filterFrom = Object.assign(this.filterFrom, params)
      this.search(1)
    }
  }
}
      this.filterFrom = Object.assign(this.filterFrom, params);
      this.search(1);
    },
  },
};
</script>
<style scoped>
</style>
<style scoped></style>