123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 |
- <template>
- <a-card size="small" :bordered="false" class="bulkWarehousingOrderList-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div ref="tableSearch" class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-item label="创建时间">
- <rangeDate ref="rangeDate" @change="dateChange" />
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="散件单号">
- <a-input id="bulkWarehousingOrderList-sparePartsPurchaseNo" v-model.trim="queryParam.sparePartsPurchaseNo" allowClear placeholder="请输入散件单号"/>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="供应商" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
- <a-select
- id="bulkWarehousingOrderList-supplierSn"
- placeholder="请选择供应商"
- allowClear
- v-model="queryParam.supplierSn"
- :showSearch="true"
- option-filter-prop="children"
- :filter-option="filterOption">
- <a-select-option v-for="item in supplierList" :key="item.supplierSn" :value="item.supplierSn">{{ item.supplierName }}</a-select-option>
- </a-select>
- </a-form-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="6" :sm="24">
- <a-form-item label="业务状态">
- <v-select
- v-model="queryParam.state"
- ref="state"
- id="bulkWarehousingOrderList-state"
- code="SPARE_PARTS_PURCHASE"
- placeholder="请选择业务状态"
- allowClear
- ></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="财务状态">
- <v-select
- v-model="queryParam.settleState"
- ref="settleState"
- id="bulkWarehousingOrderList-settleState"
- code="FINANCIAL_PAY_STATUS"
- placeholder="请选择财务状态"
- allowClear
- ></v-select>
- </a-form-item>
- </a-col>
- </template>
- <a-col :md="6" :sm="24">
- <span class="table-page-search-submitButtons">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="bulkWarehousingOrderList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm()" :disabled="disabled" id="bulkWarehousingOrderList-reset">重置</a-button>
- <a-button
- style="margin-left: 5px"
- type="primary"
- class="button-warning"
- @click="handleExport"
- :disabled="disabled"
- :loading="exportLoading"
- v-if="$hasPermissions('B_bulkWarehousingOrder_export')"
- id="bulkWarehousingOrderList-export">导出</a-button>
- <a @click="advanced=!advanced" style="margin-left: 5px">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </span>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 操作按钮 -->
- <div class="table-operator">
- <a-button v-if="$hasPermissions('B_bulkWarehousingOrder_add')" id="bulkWarehousingOrderList-add" type="primary" class="button-error" @click="handleAdd">新增</a-button>
- </div>
- <!-- alert -->
- <a-alert type="info" style="margin-bottom:10px">
- <div slot="message">
- 共 <strong>{{ dataTotalCount }}</strong> 条记录,
- 总数量合计 <strong>{{ productTotal&&(productTotal.productTotalQty || productTotal.productTotalQty==0) ? productTotal.productTotalQty : '--' }}</strong> ,
- 总金额合计 <strong>{{ productTotal&&(productTotal.productTotalCost || productTotal.productTotalCost==0) ? '¥'+productTotal.productTotalCost : '--' }}</strong>
- </div>
- </a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+84.5+'px' }"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ x: 1120, y: tableHeight }"
- :defaultLoadData="false"
- bordered>
- <!-- 散件单号 -->
- <template slot="sparePartsPurchaseNo" slot-scope="text, record">
- <span v-if="$hasPermissions('B_bulkWarehousingOrder_detail')" style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ record.sparePartsPurchaseNo }}</span>
- <span v-else>{{ record.sparePartsPurchaseNo }}</span>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <a-button
- size="small"
- type="link"
- v-if="record.state != 'FINISH' && $hasPermissions('B_bulkWarehousingOrder_edit')"
- @click="handleEdit(record)"
- class="button-info"
- id="bulkWarehousingOrderList-edit-btn">编辑</a-button>
- <a-button
- size="small"
- type="link"
- v-if="record.state == 'WAIT_PUT_WAREHOUSE' && $hasPermissions('B_bulkWarehousingOrder_put')"
- @click="handleWarehouse(record)"
- class="button-primary"
- id="bulkWarehousingOrderList-warehouse-btn">入库</a-button>
- <a-button
- size="small"
- type="link"
- v-if="record.state != 'FINISH' && $hasPermissions('B_bulkWarehousingOrder_del')"
- @click="handleDel(record)"
- class="button-error"
- id="bulkWarehousingOrderList-del-btn">删除</a-button>
- <span v-if="(record.state == 'FINISH' || !$hasPermissions('B_bulkWarehousingOrder_edit')) &&(record.state == 'FINISH' || !$hasPermissions('B_bulkWarehousingOrder_del')) &&(record.state != 'WAIT_PUT_WAREHOUSE' || !$hasPermissions('B_bulkWarehousingOrder_put'))">--</span>
- </template>
- </s-table>
- </a-spin>
- <!-- 选择基本信息弹框 -->
- <basic-info-modal :openModal="openModal" @ok="handleOk" @close="openModal=false" />
- </a-card>
- </template>
- <script>
- import moment from 'moment'
- import { STable, VSelect } from '@/components'
- import rangeDate from '@/views/common/rangeDate.vue'
- import basicInfoModal from './basicInfoModal.vue'
- import { sparePartsPurList, sparePartsPurCount, sparePartsPurDel, sparePartsPurPut, sparePartsPurExport } from '@/api/sparePartsPur'
- import { supplierAllList } from '@/api/supplier'
- export default {
- components: { STable, VSelect, basicInfoModal, rangeDate },
- data () {
- return {
- spinning: false,
- advanced: true, // 高级搜索 展开/关闭
- disabled: false, // 查询、重置按钮是否可操作
- exportLoading: false, // 导出loading
- openModal: false, // 基本信息弹框是否显示
- supplierList: [], // 供应商列表数据
- tableHeight: 0,
- // 查询参数
- queryParam: {
- beginDate: '',
- endDate: '',
- sparePartsPurchaseNo: '', // 散件单号
- supplierSn: undefined, // 供应商
- state: undefined, // 单据状态
- settleState: undefined // 结算状态
- },
- // 表头
- columns: [
- { title: '序号', dataIndex: 'no', width: 70, align: 'center' },
- { title: '散件单号', scopedSlots: { customRender: 'sparePartsPurchaseNo' }, width: 180, align: 'center' },
- { title: '创建时间', dataIndex: 'createDate', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '供应商', dataIndex: 'supplierName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '产品款数', dataIndex: 'productTotalCategory', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '总数量', dataIndex: 'productTotalQty', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '总金额', dataIndex: 'productTotalCost', width: 80, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '业务状态', dataIndex: 'stateDictValue', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '财务状态', dataIndex: 'settleStateDictValue', width: 80, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.spinning = true
- return sparePartsPurList(Object.assign(parameter, this.queryParam)).then(res => {
- const data = res.data
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- }
- this.disabled = false
- this.spinning = false
- this.dataTotalCount = data.count || 0
- this.getTotal(Object.assign(parameter, this.queryParam))
- return data
- })
- },
- productTotal: null,
- dataTotalCount: 0 // 列表数据总条数
- }
- },
- methods: {
- // 时间 change
- dateChange (date) {
- this.queryParam.beginDate = date[0]
- this.queryParam.endDate = date[1]
- },
- // 合计
- getTotal (param) {
- sparePartsPurCount(param).then(res => {
- if (res.status == 200 && res.data) {
- this.productTotal = res.data
- } else {
- this.productTotal = null
- }
- })
- },
- // 新增
- handleAdd () {
- this.openModal = true
- },
- // 基本信息 保存
- handleOk (row) {
- this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/add/${row.id}/${row.sparePartsPurchaseSn}` })
- },
- // 编辑
- handleEdit (row) {
- this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/edit/${row.id}/${row.sparePartsPurchaseSn}` })
- },
- // 详情
- handleDetail (row) {
- this.$router.push({ path: `/bulkManagement/bulkWarehousingOrder/detail/${row.id}/${row.sparePartsPurchaseSn}` })
- },
- // 入库
- handleWarehouse (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确定要入库吗?',
- centered: true,
- onOk () {
- _this.spinning = true
- sparePartsPurPut({ id: row.id }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- })
- },
- // 删除
- handleDel (row) {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '删除后不可恢复,确定要进行删除吗?',
- centered: true,
- onOk () {
- _this.spinning = true
- sparePartsPurDel({ id: row.id }).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$refs.table.refresh()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- }
- })
- },
- // 重置
- resetSearchForm () {
- this.$refs.rangeDate.resetDate()
- this.queryParam.beginDate = ''
- this.queryParam.endDate = ''
- this.queryParam.sparePartsPurchaseNo = ''
- this.queryParam.supplierSn = undefined
- this.queryParam.state = undefined
- this.queryParam.settleState = undefined
- this.$refs.table.refresh(true)
- },
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- // 导出
- handleExport () {
- const _this = this
- const params = this.queryParam
- this.exportLoading = true
- this.spinning = true
- sparePartsPurExport(params).then(res => {
- this.exportLoading = false
- this.spinning = false
- if (res.type == 'application/json') {
- var reader = new FileReader()
- reader.addEventListener('loadend', function () {
- const obj = JSON.parse(reader.result)
- _this.$notification.error({
- message: '提示',
- description: obj.message
- })
- })
- reader.readAsText(res)
- } else {
- this.download(res)
- }
- })
- },
- download (data) {
- if (!data) { return }
- const url = window.URL.createObjectURL(new Blob([data]))
- const link = document.createElement('a')
- link.style.display = 'none'
- link.href = url
- const a = moment().format('YYYYMMDDHHmmss')
- const fname = '散件入库单' + a
- link.setAttribute('download', fname + '.xlsx')
- document.body.appendChild(link)
- link.click()
- },
- // 供应商下拉数据
- getSupplierList () {
- supplierAllList().then(res => {
- if (res.status == 200) {
- this.supplierList = res.data
- } else {
- this.supplierList = []
- }
- })
- },
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- this.openModal = false
- this.getSupplierList()
- },
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 270
- }
- },
- watch: {
- advanced (newValue, oldValue) {
- const _this = this
- setTimeout(() => {
- _this.setTableH()
- }, 400)
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- // 仅刷新列表,不重置页面
- if (this.$store.state.app.updateList) {
- this.pageInit()
- this.$refs.table.refresh()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
|