From 2126cd24b8a0174ac0597340917c0a4595f72254 Mon Sep 17 00:00:00 2001 From: zjf <zhangjf@probim.com.cn> Date: Fri, 24 Feb 2023 15:19:25 +0800 Subject: [PATCH] 订阅条件导出 --- src/api/common.js | 20 +++ src/views/clients/components/CRMExport.vue | 8 src/api/pwsApi/subscriptions.js | 16 -- src/views/PWS/Subscriptions.vue | 269 +++++++++++--------------------------------- 4 files changed, 89 insertions(+), 224 deletions(-) diff --git a/src/api/common.js b/src/api/common.js index ed9309f..9a073e3 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -287,9 +287,25 @@ responseType: 'blob' }) } -export function DownloadSubscriptions (data) { +export function ExportSubscriptionsExcel (data) { + // let params = '' + // for (const key in data) { + // console.log(key + ':' + data[key]) + // params = params + (data[key] ? `&${key}=${data[key]}` : '') + // } + // console.log(params) return request({ - url: '/AutoDesk/download/subscriptions/' + data.taskId, + url: '/AutoDesk/subscriptions/ExportExcel?AutoRenewingContractText=' + (data.AutoRenewingContractText === 'Auto-RenewingContract' ? data.AutoRenewingContractText : '') + + (data.EndCustomerStateProvince + ? '&EndCustomerStateProvince=' + encodeURIComponent(data.EndCustomerStateProvince) : '') + + (data.ProductLine + ? '&ProductLine=' + encodeURIComponent(data.ProductLine) : '') + + (data.Term + ? '&Term=' + data.Term : '') + + (data.StartContractEndDate + ? '&StartContractEndDate=' + data.StartContractEndDate : '') + + (data.EndContractEndDate + ? '&EndContractEndDate=' + data.EndContractEndDate : ''), method: 'get', responseType: 'blob' }) diff --git a/src/api/pwsApi/subscriptions.js b/src/api/pwsApi/subscriptions.js index d2f4635..d95ed38 100644 --- a/src/api/pwsApi/subscriptions.js +++ b/src/api/pwsApi/subscriptions.js @@ -1,18 +1,2 @@ import request from '@/utils/request' -export function ExportSubscriptionsTask (data) { - return request({ - url: '/AutoDesk/create/export-subscriptions-task', - method: 'post', - data: data - }) -} -export function GetSubscriptionsTask (data) { - return request({ - url: '/AutoDesk/export-subscriptions-task/paged?PageIndex=' + data.PageIndex + '&PageSize=' + data.PageSize + - (data.StartTime ? '&StartTime=' + data.StartTime : '') + - (data.EndTime ? '&EndTime=' + data.EndTime : '') + - (data.TaskStatus ? '&TaskStatus=' + data.TaskStatus : ''), - method: 'get' - }) -} diff --git a/src/views/PWS/Subscriptions.vue b/src/views/PWS/Subscriptions.vue index 8efde5d..888a01f 100644 --- a/src/views/PWS/Subscriptions.vue +++ b/src/views/PWS/Subscriptions.vue @@ -6,9 +6,28 @@ main-title="PWS API" /> <el-form :inline="true" :model="headObj" class="selectInline"> <el-form-item> - <span>开始时间:</span> + <div style='display: flex;'> + <span style="margin-right: 12px">筛选方式:</span> + <el-select v-model="headObj.AutoRenewingContractText" placeholder="请选择" @change="renewalMethodChange"> + <el-option key="1" label="自动续约合约" value="Auto-RenewingContract"></el-option> + <el-option key="2" label="合约到期时间" value="NoAuto-RenewingContract"></el-option> + </el-select> + </div> + </el-form-item> + <el-form-item v-if="headObj.AutoRenewingContractText == 'NoAuto-RenewingContract'"> + <span>合约到期开始日期:</span> <el-date-picker - v-model="headObj.startDateSince" + v-model="headObj.StartContractEndDate" + type="date" + placeholder="选择开始日期" + value-format="yyyy-MM-dd" + :picker-options="pickerOptions"> + </el-date-picker> + </el-form-item> + <el-form-item v-if="headObj.AutoRenewingContractText == 'NoAuto-RenewingContract'"> + <span>合约到期结束日期:</span> + <el-date-picker + v-model="headObj.EndContractEndDate" type="date" placeholder="选择开始日期" value-format="yyyy-MM-dd" @@ -16,84 +35,33 @@ </el-date-picker> </el-form-item> <el-form-item> - <span>截止时间:</span> - <el-date-picker - v-model="headObj.lastModifiedSince" - type="date" - placeholder="选择最后修改日期" - value-format="yyyy-MM-dd" - :picker-options="pickerOptions"> - </el-date-picker> + <span>产品线:</span> + <el-input + style="width: 200px" + v-model="headObj.ProductLine" + placeholder="请输入产品线"/> </el-form-item> - <!-- <el-form-item> - <div style='display: flex;'> - <span style="margin-right: 12px">状态:</span> - <el-checkbox-group v-model="headObj.subscriptionStatus" style="display: flex; align-items: center;"> - <el-checkbox label="活动"></el-checkbox> - <el-checkbox label="非活动"></el-checkbox> - <el-checkbox label="已过期"></el-checkbox> - </el-checkbox-group> - </div> - </el-form-item> --> <el-form-item> - <el-button type="primary" @click="onSubmit('query')">新建导出任务</el-button> + <span>最终客户帐户所在地:</span> + <el-input + style="width: 200px" + v-model="headObj.EndCustomerStateProvince" + placeholder="请输入最终客户帐户所在地"/> + </el-form-item> + <el-form-item> + <div style='display: flex;'> + <span style="margin-right: 12px">许可年限:</span> + <el-select v-model="headObj.Term" placeholder="请选择"> + <el-option key="1" label="一年" value="Annual"></el-option> + <el-option key="3" label="三年" value="3-Year"></el-option> + </el-select> + </div> + </el-form-item> + <el-form-item> + <el-button type="primary" @click="exportFile()">导出</el-button> <el-button @click="onSubmit('reset')">重置</el-button> </el-form-item> </el-form> - <el-card class="el-card"> - <el-table - v-loading="loading" - id="crm-table" - :data="tableData" - :height="tableHeight" - :cell-style="cellStyle" - class="n-table--border" - border - highlight-current-row - style="width: 100%" - @row-click="rowClick"> - <el-table-column - v-for="(item, index) in fieldList" - :key="index" - :prop="item.field" - :label="item.name" - :formatter="fieldFormatter" - show-overflow-tooltip> - <template - slot="header" - slot-scope="scope"> - <div class="table-head-name">{{ scope.column.label }}</div> - </template> - </el-table-column> - <el-table-column - prop="operation"> - <template - title="hhhhhhhhh" - slot="header" - slot-scope="scope"> - <div class="table-head-name">操作</div> - </template> - <template slot-scope="scope"> - <span v-if="scope.row.TaskStatus === 0" style="font-size: 12px; color: #909398; font-weight: 500;">等待处理</span> - <span v-else-if="scope.row.TaskStatus === 1" style="font-size: 12px; color: #80BF50; font-weight: 500;">正在处理</span> - <span v-else-if="scope.row.TaskStatus === 2" style="font-size: 12px; color: #5B88F7; font-weight: 500;">导出完成</span> - <span v-else-if="scope.row.TaskStatus === 3" style="font-size: 12px; color: #DBA450; font-weight: 500;">导出失败</span> - <el-button style="margin-left: 12px" v-if="scope.row.TaskStatus === 2" size="mini" type="primary" @click='exportFile(scope.row)'>导出</el-button> - </template> - </el-table-column> - </el-table> - <div class="p-contianer" v-if='total>0'> - <el-pagination - :current-page="currentPage" - :page-sizes="pageSizes" - :page-size.sync="pageSize" - :total="total" - class="p-bar" - layout="total, sizes, prev, pager, next, jumper" - @size-change="handleSizeChange" - @current-change="handleCurrentChange"/> - </div> - </el-card> <c-r-m-export :show="showCRMExport" :crm-type="crmType" @@ -104,7 +72,6 @@ </template> <script> -import { ExportSubscriptionsTask, GetSubscriptionsTask } from '@/api/pwsApi/subscriptions' import CRMListHead from '../clients/components/CRMListHead' import CRMExport from '../clients/components/CRMExport' export default { @@ -133,13 +100,14 @@ showCRMExport: false, crmType: 'subscriptions', headObj: { - startDateSince: '', - lastModifiedSince: '', - subscriptionStatus: [] + AutoRenewingContractText: '', // 自动续约合同 + StartContractEndDate: '', // 开始时间 + EndContractEndDate: '', // 结束时间 + ProductLine: '', // 产品线 + EndCustomerStateProvince: '', // 最终客户帐户所在地 + Term: '' // 许可年限 }, - exportHeadObj: { - taskId: '' - }, + exportHeadObj: {}, pickerOptions: { disabledDate (time) { return time.getTime(new Date()) > Date.now() @@ -148,125 +116,32 @@ } }, mounted () { - var self = this - /** 控制table的高度 */ - window.onresize = () => { - self.updateTableHeight() - } - this.getList() }, methods: { - getList () { - this.loading = true - let params = { - 'PageIndex': this.currentPage, - 'PageSize': this.pageSize + // 选择非续约合同后清空开始 结束日期 + renewalMethodChange (value) { + console.log(value) + if (value === 'Auto-RenewingContract') { + this.headObj.StartContractEndDate = '' + this.headObj.EndContractEndDate = '' } - GetSubscriptionsTask(params) - .then(res => { - if (res.data.ErrorCode === 200) { - if (res.data.Result.Count > 0) { - this.tableData = res.data.Result.List - } else { - this.tableData = [] - } - this.total = res.data.Result.Count - this.loading = false - } else { - this.$message.error(res.data.Message) - this.loading = false - } - }) - .catch(() => { - this.loading = false - }) - }, - // 更改每页展示数量 - handleSizeChange (val) { - // Lockr.set('crmPageSizes', val) - this.pageSize = val - this.getList() - }, - // 更改当前页数 - handleCurrentChange (val) { - this.currentPage = val - this.getList() - }, - updateTableHeight () { - var offsetHei = document.documentElement.clientHeight - // var removeHeight = Object.keys(this.filterObj).length > 0 ? 310 : 240 - var removeHeight = 240 - this.tableHeight = offsetHei - removeHeight - }, - cellStyle ({ row, column, rowIndex, columnIndex }) { - return { textAlign: 'left' } - }, - rowClick (row, column, event) { }, queryList (data) { console.log(data) }, - // 列表信息格式化 - fieldFormatter (row, column) { - if (column.property === 'Status') { - switch (row[column.property]) { - case true: - row[column.property] = '是' - break - case false: - row[column.property] = '否' - break - } - } - return row[column.property] || '--' - }, onSubmit (val) { - if (val === 'query') { - if (this.headObj.startDateSince === '') { - this.$message.error('请选择导出任务的开始时间') - return - } - this.loading = true - // let status = '' - // this.headObj.subscriptionStatus.forEach((item) => { - // if (status === '') { - // status = item - // } else { - // status = status + ',' + item - // } - // }) - // this.headObj.subscriptionStatus = status - let params - if (this.headObj.lastModifiedSince === '') { - params = { - startDateSince: this.headObj.startDateSince - } - } else { - params = { - startDateSince: this.headObj.startDateSince, - lastModifiedSince: this.headObj.lastModifiedSince - } - } - ExportSubscriptionsTask(params) - .then(res => { - if (res.data.ErrorCode === 200) { - this.loading = false - this.getList() - } else { - this.$message.error(res.data.Message) - this.loading = false - } - }) - .catch(() => { - this.loading = false - }) - } else if (val === 'reset') { - this.headObj = {} + this.headObj = { + AutoRenewingContractText: '', // 自动续约合同 + StartContractEndDate: '', // 开始时间 + EndContractEndDate: '', // 结束时间 + ProductLine: '', // 产品线 + EndCustomerStateProvince: '', // 最终客户帐户所在地 + Term: '' // 许可年限 } }, - exportFile (item) { - console.log(item) - this.exportHeadObj.taskId = item.Id + exportFile () { + console.log(this.headObj) + this.exportHeadObj = this.headObj // 需要设置参数 this.headObj this.showCRMExport = true } @@ -301,15 +176,5 @@ line-height: 28px; } } -/** 分页布局 */ -.p-contianer { - position: relative; - background-color: white; - height: 44px; - .p-bar { - float: right; - margin: 5px 0 0 0; - font-size: 14px !important; - } -} + </style> diff --git a/src/views/clients/components/CRMExport.vue b/src/views/clients/components/CRMExport.vue index add542a..161a76f 100644 --- a/src/views/clients/components/CRMExport.vue +++ b/src/views/clients/components/CRMExport.vue @@ -43,7 +43,7 @@ OutputContacterToExcel, OutputSalesChanceToExcel, OutputOtherSalesChanceToExcel, - DownloadSubscriptions + ExportSubscriptionsExcel } from '@/api/common' export default { @@ -234,7 +234,7 @@ } } else if (this.crmType === 'subscriptions') { params = { - 'taskId': this.headObj ? this.headObj.taskId : '' + ...this.headObj } } let month = new Date().getMonth() + 1 @@ -245,7 +245,7 @@ contacts: OutputContacterToExcel, business: OutputSalesChanceToExcel, businessChances: OutputOtherSalesChanceToExcel, - subscriptions: DownloadSubscriptions + subscriptions: ExportSubscriptionsExcel }[this.crmType] console.log(request) request(params) @@ -279,7 +279,7 @@ } else if (this.crmType === 'contacts') { downloadElement.download = `客户联系人列表` + timer + `.xlsx` } else if (this.crmType === 'subscriptions') { - downloadElement.download = `订阅列表` + timer + `.zip` + downloadElement.download = `订阅列表` + timer + `.xlsx` } else { downloadElement.download = `列表` + timer + `.xlsx` } -- Gitblit v1.9.3