123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- <template>
- <a-card size="small" :bordered="false" class="allocationDetailsList-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div class="table-page-search-wrapper">
- <a-form-model
- id="allocationDetailsList-form"
- ref="ruleForm"
- class="form-model-con"
- layout="inline"
- :model="queryParam"
- :rules="rules"
- :labelCol="labelCol"
- :wrapperCol="wrapperCol"
- @keyup.enter.native="handleSearch" >
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-model-item label="调拨开单日期" prop="time">
- <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
- </a-form-model-item>
- </a-col>
- <a-col :md="5" :sm="24">
- <a-form-model-item label="产品名称">
- <a-input id="allocationDetailsList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="5" :sm="24">
- <a-form-model-item label="品牌分类">
- <v-select code="BRAND_TYPE" id="allocationDetailsList-productBrandTypeSn" v-model="queryParam.productBrandTypeSn" allowClear placeholder="请选择品牌分类"></v-select>
- </a-form-model-item>
- </a-col>
- <template v-if="advanced">
- <a-col :md="7" :sm="24">
- <a-form-model-item label="产品品牌">
- <ProductBrand id="allocationDetailsList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品编码">
- <a-input id="allocationDetailsList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="调拨类型名称">
- <a-select id="allocationDetailsList-allocateTypeSn" v-model="queryParam.allocateTypeSn" placeholder="请选择调拨类型名称" allowClear >
- <a-select-option v-for="item in allocateTypeList" :key="item.allocateTypeSn" :value="item.allocateTypeSn">{{ item.name }}</a-select-option>
- </a-select>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="操作员">
- <a-select id="allocationDetailsList-creatorId" v-model="queryParam.creatorId" placeholder="请选择操作员" allowClear >
- <a-select-option v-for="item in operatorList" :key="item.sn" :value="item.sn">{{ item.name }}</a-select-option>
- </a-select>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="调拨单号">
- <a-input id="allocationDetailsList-allocateNo" v-model.trim="queryParam.allocateNo" allowClear placeholder="请输入调拨单号"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="产品分类">
- <a-cascader
- @change="changeProductType"
- expand-trigger="hover"
- change-on-select
- :options="productTypeList"
- :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
- id="allocationDetailsList-productType"
- placeholder="请选择产品分类"
- allowClear
- v-model="productType" />
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="客户名称">
- <a-input id="allocationDetailsList-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入客户名称"/>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="客户级别">
- <v-select code="DEALER_LEVEL" id="allocationDetailsList-dealerLevel" v-model="queryParam.dealerLevel" allowClear placeholder="请选择客户级别"></v-select>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="所在区域">
- <subarea id="allocationDetailsList-subarea" v-model="queryParam.subareaSn"></subarea>
- </a-form-model-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-model-item label="地区">
- <a-form-model-item prop="dealerProvinceSn">
- <a-select id="allocationDetailsList-dealerProvinceSn" allowClear v-model="queryParam.dealerProvinceSn" placeholder="请选择省">
- <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
- </a-select>
- </a-form-model-item>
- </a-form-model-item>
- </a-col>
- </template>
- <a-col :md="8" :sm="24" style="margin-bottom: 10px;">
- <a-button
- style="margin-left: 0px"
- type="primary"
- class="button-info"
- size="small"
- @click="handleStock"
- id="allocationDetailsList-stockDate">盘点区间日期</a-button>
- <a-button type="primary" @click="handleSearch" :disabled="disabled" id="allocationDetailsList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="allocationDetailsList-reset">重置</a-button>
- <a-button
- style="margin-left: 5px"
- type="primary"
- class="button-warning"
- @click="handleExport"
- :disabled="disabled"
- :loading="exportLoading"
- v-if="$hasPermissions('B_allocationDetails_Export')"
- id="allocationDetailsList-export">导出</a-button>
- <a @click="advanced=!advanced">
- {{ advanced ? '收起' : '展开' }}
- <a-icon :type="advanced ? 'up' : 'down'"/>
- </a>
- </a-col>
- </a-row>
- </a-form-model>
- </div>
- <!-- 列表 -->
- <s-table
- class="sTable"
- ref="table"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :defaultLoadData="false"
- :scroll="{ x: 2090 }"
- bordered>
- <template slot="footer">
- <a-row :gutter="15">
- <a-col :md="4" :sm="24">总数量:{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</a-col>
- <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowCost')">总成本价:{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? totalData.totalCost : '--' }}</a-col>
- <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowCost')">总毛利:{{ (totalData && (totalData.totalGrossProfit || totalData.totalGrossProfit==0)) ? totalData.totalGrossProfit : '--' }}</a-col>
- <a-col :md="4" :sm="24" v-if="$hasPermissions('B_isShowPrice')">总售价:{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? totalData.totalPrice : '--' }}</a-col>
- </a-row>
- </template>
- </s-table>
- </a-spin>
- <!-- 导出提示框 -->
- <reportModal :visible="showExport" @close="showExport=false"></reportModal>
- </a-card>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import getDate from '@/libs/getDate.js'
- import { STable, VSelect } from '@/components'
- import rangeDate from '@/views/common/rangeDate.vue'
- import reportModal from '@/views/common/reportModal.vue'
- import subarea from '@/views/common/subarea.js'
- import { productBrandQuery } from '@/api/productBrand'
- import { productTypeQuery } from '@/api/productType'
- import { getArea } from '@/api/data'
- import { allocateTypeAllList } from '@/api/allocateType'
- import ProductBrand from '@/views/common/productBrand.js'
- import { hdExportExcel } from '@/libs/exportExcel'
- import { userQueryList } from '@/api/power-user'
- import { allocateReportDetailList, allocateReportDetailCount, allocateReportDetailExport } from '@/api/allocateReport'
- export default {
- name: 'AllocationDetailsList',
- mixins: [commonMixin],
- components: { STable, VSelect, rangeDate, subarea, ProductBrand, reportModal },
- data () {
- return {
- spinning: false,
- advanced: false, // 高级搜索 展开/关闭
- exportLoading: false,
- tableHeight: 0,
- showExport: false,
- queryParam: { // 查询条件
- time: [
- getDate.getCurrMonthDays().starttime,
- getDate.getCurrMonthDays().endtime
- ],
- beginDate: getDate.getCurrMonthDays().starttime,
- endDate: getDate.getCurrMonthDays().endtime,
- productName: '',
- productBrandTypeSn: undefined,
- productBrandSn: undefined, // 产品品牌
- productCode: '',
- allocateTypeSn: undefined, // 调拨类型
- creatorId: undefined,
- allocateNo: '',
- productTypeSn1: '', // 产品一级分类
- productTypeSn2: '', // 产品二级分类
- productTypeSn3: '', // 产品三级分类
- dealerName: '',
- dealerLevel: undefined,
- subareaSn: undefined,
- dealerProvinceSn: undefined
- },
- productType: [],
- labelCol: { span: 8 },
- wrapperCol: { span: 16 },
- rules: {
- 'time': [{ required: true, message: '请选择调拨开单日期', trigger: 'change' }]
- },
- disabled: false, // 查询、重置按钮是否可操作
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- const params = Object.assign(parameter, this.queryParam)
- delete params.time
- this.spinning = true
- if (params.beginDate) {
- return allocateReportDetailList(params).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- // 总计
- this.getCount(params)
- 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
- return data
- })
- } else {
- const _this = this
- return new Promise(function (resolve, reject) {
- const data = {
- pageNo: 1,
- pageSize: 10,
- list: [],
- count: 0
- }
- _this.disabled = false
- _this.spinning = false
- _this.$message.info('请选择调拨开单日期')
- resolve(data)
- })
- }
- },
- allocateTypeList: [], // 调拨类型
- productBrandList: [], // 品牌下拉数据
- productTypeList: [], // 分类下拉数据
- operatorList: [], // 操作员下拉数据
- addrProvinceList: [], // 省下拉
- totalData: null // 合计
- }
- },
- computed: {
- columns () {
- const arr = [
- { title: '区域', dataIndex: 'subareaNames', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '调拨单号', dataIndex: 'allocateNo', width: 160, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
- { title: '调拨开单日期', dataIndex: 'allocateDate', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '省份', dataIndex: 'dealerProvinceName', width: 90, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '客户名称', dataIndex: 'targetName', align: 'center', sorter: true, customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '品牌', dataIndex: 'productBrandName', width: 130, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '二级分类', dataIndex: 'productTypeName2', width: 130, align: 'center', customRender: function (text) { return text || '--' } },
- { title: '产品名称', dataIndex: 'productName', align: 'left', sorter: true, customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '产品编码', dataIndex: 'productCode', width: 150, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
- { title: '调拨数量', dataIndex: 'qty', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '单位', dataIndex: 'productUnit', width: 50, align: 'center', customRender: function (text) { return text || '--' } },
- // { title: '成本价', dataIndex: 'cost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- // { title: '售价', dataIndex: 'price', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- // { title: '总成本价', dataIndex: 'totalCost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- // { title: '毛利', dataIndex: 'grossProfit', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
- { title: '仓库', dataIndex: 'warehouseName', width: 90, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
- { title: '仓位', dataIndex: 'warehouseLocationName', width: 90, align: 'center', sorter: true, customRender: function (text) { return text || '--' } },
- { title: '操作员', dataIndex: 'creatorName', width: 100, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '调拨类型', dataIndex: 'allocateTypeName', width: 80, align: 'center', customRender: function (text) { return text || '--' } }
- ]
- if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
- arr.splice(12, 0, { title: '成本价', dataIndex: 'cost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
- arr.splice(14, 0, { title: '总成本价', dataIndex: 'totalCost', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
- arr.splice(15, 0, { title: '毛利', dataIndex: 'grossProfit', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
- }
- if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
- const ind = this.$hasPermissions('B_isShowCost') ? 13 : 12
- arr.splice(ind, 0, { title: '售价', dataIndex: 'price', width: 70, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
- }
- return arr
- }
- },
- methods: {
- // 盘点库存日期
- handleStock () {
- this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
- },
- // 创建时间 change
- dateChange (date) {
- if (date[0] && date[1]) {
- this.queryParam.time = date
- } else {
- this.queryParam.time = []
- }
- this.queryParam.beginDate = date[0] || ''
- this.queryParam.endDate = date[1] || ''
- },
- // 合计
- getCount (params) {
- allocateReportDetailCount(params).then(res => {
- if (res.status == 200) {
- this.totalData = res.data
- } else {
- this.totalData = null
- }
- })
- },
- // 查询
- handleSearch () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- _this.$refs.table.refresh(true)
- } else {
- console.log('error submit!!')
- return false
- }
- })
- },
- // 重置
- resetSearchForm () {
- this.queryParam.time = [
- getDate.getCurrMonthDays().starttime,
- getDate.getCurrMonthDays().endtime
- ]
- this.$refs.rangeDate.resetDate(this.queryParam.time)
- this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
- this.queryParam.endDate = getDate.getCurrMonthDays().endtime
- this.queryParam.productName = ''
- this.queryParam.productBrandTypeSn = undefined
- this.queryParam.productBrandSn = undefined
- this.queryParam.productCode = ''
- this.queryParam.allocateTypeSn = undefined
- this.queryParam.creatorId = undefined
- this.queryParam.allocateNo = ''
- this.queryParam.productTypeSn1 = ''
- this.queryParam.productTypeSn2 = ''
- this.queryParam.productTypeSn3 = ''
- this.queryParam.dealerName = ''
- this.queryParam.dealerLevel = undefined
- this.queryParam.subareaSn = undefined
- this.queryParam.dealerProvinceSn = undefined
- this.productType = []
- this.$refs.ruleForm.resetFields()
- this.totalData = null
- this.$refs.table.clearTable()
- },
- // 导出
- handleExport () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const params = _this.queryParam
- _this.showExport = true
- _this.exportLoading = true
- _this.spinning = true
- hdExportExcel(allocateReportDetailExport, params, '调拨明细报表', function () {
- _this.exportLoading = false
- _this.spinning = false
- })
- } else {
- console.log('error submit!!')
- return false
- }
- })
- },
- // 产品分类 change
- changeProductType (val, opt) {
- this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
- this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
- this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
- },
- // 产品品牌 列表
- getProductBrand () {
- productBrandQuery({}).then(res => {
- if (res.status == 200) {
- this.productBrandList = res.data
- } else {
- this.productBrandList = []
- }
- })
- },
- // 产品分类 列表
- getProductType () {
- productTypeQuery({}).then(res => {
- if (res.status == 200) {
- this.productTypeList = res.data
- } else {
- this.productTypeList = []
- }
- })
- },
- // 调拨类型
- getAllocateTypeAllList () {
- allocateTypeAllList().then(res => {
- if (res.status == 200) {
- this.allocateTypeList = res.data
- } else {
- this.allocateTypeList = []
- }
- })
- },
- // 操作员
- getUserList () {
- userQueryList({}).then(res => {
- if (res.status == 200) {
- this.operatorList = res.data
- } else {
- this.operatorList = []
- }
- })
- },
- // 省/市/区
- getArea (leve, sn) {
- let params
- if (leve == 'province') {
- params = { type: '2' }
- } else {
- params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
- }
- getArea(params).then(res => {
- if (res.status == 200) {
- if (leve == 'province') {
- this.addrProvinceList = res.data || []
- } else if (leve == 'city') {
- this.addrCityList = res.data || []
- } else if (leve == 'district') {
- this.addrDistrictList = res.data || []
- }
- } else {
- if (leve == 'province') {
- this.addrProvinceList = []
- } else if (leve == 'city') {
- this.addrCityList = []
- } else if (leve == 'district') {
- this.addrDistrictList = []
- }
- }
- })
- },
- pageInit () {
- this.getProductBrand()
- this.getProductType()
- this.getAllocateTypeAllList()
- this.getUserList()
- this.getArea('province')
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- },
- beforeRouteEnter (to, from, next) {
- next(vm => {})
- }
- }
- </script>
|