list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="allocationOrderTotalList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="allocationOrderTotalList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. :labelCol="labelCol"
  14. :wrapperCol="wrapperCol"
  15. @keyup.enter.native="handleSearch" >
  16. <a-row :gutter="15">
  17. <a-col :md="6" :sm="24">
  18. <a-form-model-item label="调拨开单日期" prop="time">
  19. <rangeDate ref="rangeDate" id="allocationOrderTotalList-time" :value="queryParam.time" @change="dateChange" />
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-model-item label="调拨单号">
  24. <a-input id="allocationOrderTotalList-allocateNo" v-model.trim="queryParam.allocateNo" allowClear placeholder="请输入调拨单号"/>
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-item label="客户名称">
  29. <a-input id="allocationOrderTotalList-targetName" v-model.trim="queryParam.targetName" allowClear placeholder="请输入客户名称搜索"/>
  30. </a-form-item>
  31. </a-col>
  32. <template v-if="advanced">
  33. <a-col :md="6" :sm="24">
  34. <a-form-model-item label="客户类型">
  35. <v-select
  36. v-model="queryParam.targetType"
  37. id="allocationOrderTotalList-targetType"
  38. code="TARGET_TYPE"
  39. placeholder="请选择客户类型"
  40. allowClear></v-select>
  41. </a-form-model-item>
  42. </a-col>
  43. <a-col :md="6" :sm="24">
  44. <a-form-model-item label="费用/调拨类型">
  45. <AllocateType id="allocationOrderTotalList-allocateTypeSn" v-model="allocateTypeVal" :changeOnSelect="true" placeholder="请选择费用/调拨类型" @change="changeAllocatype"></AllocateType>
  46. </a-form-model-item>
  47. </a-col>
  48. <a-col :md="6" :sm="24" v-show="isShowCustomerSearch">
  49. <a-form-model-item label="客服">
  50. <customerService ref="customerName" id="allocationOrderTotalList-customerName" v-model="queryParam.bizUserSn"></customerService>
  51. </a-form-model-item>
  52. </a-col>
  53. <a-col :md="6" :sm="24">
  54. <a-form-model-item label="操作员">
  55. <a-select
  56. id="allocationOrderTotalList-creatorId"
  57. allowClear
  58. v-model="queryParam.creatorId"
  59. placeholder="请选择操作员"
  60. :showSearch="true"
  61. option-filter-prop="children"
  62. :filter-option="filterOption">
  63. <a-select-option v-for="item in operatorList" :key="item.sn" :value="item.sn">{{ item.name }}</a-select-option>
  64. </a-select>
  65. </a-form-model-item>
  66. </a-col>
  67. </template>
  68. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  69. <!-- <a-button
  70. type="primary"
  71. class="button-info"
  72. size="small"
  73. @click="handleStock"
  74. id="allocationOrderTotalList-stockDate">盘点区间日期</a-button> -->
  75. <a-button style="margin-left: 5px" type="primary" @click="handleSearch" :disabled="disabled" id="allocationOrderTotalList-refresh">查询</a-button>
  76. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="allocationOrderTotalList-reset">重置</a-button>
  77. <a-button
  78. style="margin-left: 5px"
  79. type="primary"
  80. v-if="$hasPermissions('B_allocationOrderTotalList_export')"
  81. class="button-warning"
  82. @click="handleExport"
  83. :disabled="disabled"
  84. :loading="exportLoading"
  85. id="allocationOrderTotalList-export">导出</a-button>
  86. <a @click="advanced=!advanced" style="margin-left: 5px">
  87. {{ advanced ? '收起' : '展开' }}
  88. <a-icon :type="advanced ? 'up' : 'down'"/>
  89. </a>
  90. </a-col>
  91. </a-row>
  92. </a-form-model>
  93. </div>
  94. </a-card>
  95. <!-- 列表 -->
  96. <a-card size="small" :bordered="false">
  97. <a-spin :spinning="spinning" tip="Loading...">
  98. <s-table
  99. class="sTable fixPagination"
  100. ref="table"
  101. size="small"
  102. :rowKey="(record) => record.id"
  103. :columns="columns"
  104. :data="loadData"
  105. :defaultLoadData="false"
  106. bordered
  107. :style="{ height: tableHeight+84.5+'px' }"
  108. :scroll="{ y: tableHeight - 20 }">
  109. <!-- 调拨类型 -->
  110. <template slot="allocateType" slot-scope="text, record">
  111. <div>
  112. <span>{{ record.allocateSortName||'--' }}</span>
  113. <span v-if="record.allocateSortName&&record.allocateTypeName">/{{ record.allocateTypeName }}</span>
  114. </div>
  115. </template>
  116. <!-- 费用归属品类 -->
  117. <template slot="productType" slot-scope="text, record">
  118. <span v-if="record.productTypeName1">{{ record.productTypeName1 }}{{ record.productTypeName2?'>'+record.productTypeName2:'' }}{{ record.productTypeName3?'>'+record.productTypeName3:'' }}</span>
  119. <span v-else>--</span>
  120. </template>
  121. <template slot="footer">
  122. <table>
  123. <tr>
  124. <td style="width:15%"></td>
  125. <td style="width:15%"></td>
  126. <td style="width:20%"></td>
  127. <td style="width:12%;text-align: center;">总数量:{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</td>
  128. <td style="width:12%;text-align: right;"><span v-if="$hasPermissions('M_allocationOrderTotalList_salesPrice')">总售价:{{ (totalData && (totalData.totalPrice || totalData.totalPrice==0)) ? toThousands(totalData.totalPrice) : '--' }}</span></td>
  129. <td style="width:12%;text-align: right;"><span v-if="$hasPermissions('M_allocationOrderTotalList_costPrice')">总成本价:{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? toThousands(totalData.totalCost) : '--' }}</span></td>
  130. <td style="width:12%;text-align: right;"><span v-if="$hasPermissions('M_allocationOrderTotalList_costPrice')">总毛利:{{ (totalData && (totalData.totalGrossProfit || totalData.totalGrossProfit==0)) ? toThousands(totalData.totalGrossProfit) : '--' }}</span></td>
  131. <td style="width:14%"></td>
  132. </tr>
  133. </table>
  134. </template>
  135. </s-table>
  136. </a-spin>
  137. </a-card>
  138. </div>
  139. </template>
  140. <script>
  141. import { commonMixin } from '@/utils/mixin'
  142. import getDate from '@/libs/getDate.js'
  143. // 组件
  144. import { STable, VSelect } from '@/components'
  145. import { exportExcel } from '@/libs/JGPrint.js'
  146. import rangeDate from '@/views/common/rangeDate.vue'
  147. import AllocateType from '@/views/common/allocateType.js'
  148. import customerService from '@/views/common/customerService'
  149. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  150. // 接口
  151. import { allocateTypeAllList } from '@/api/allocateType'
  152. import { userQueryList } from '@/api/power-user'
  153. import { allocateReportList, allocateReportCount, allocateReportExportExcel } from '@/api/allocateReport'
  154. export default {
  155. name: 'AllocationOrderTotalList',
  156. mixins: [commonMixin],
  157. components: { STable, VSelect, rangeDate, AllocateType, customerService, dealerSubareaScopeList },
  158. data () {
  159. return {
  160. spinning: false,
  161. labelCol: { span: 8 },
  162. wrapperCol: { span: 16 },
  163. tableHeight: 0, // 表格高度
  164. advanced: true, // 高级搜索 展开/关闭
  165. // 查询条件
  166. queryParam: {
  167. // 调拨开单日期 默认值
  168. time: [
  169. getDate.getCurrMonthDays().starttime,
  170. getDate.getCurrMonthDays().endtime
  171. ],
  172. beginDate: getDate.getCurrMonthDays().starttime, // 开始日期
  173. endDate: getDate.getCurrMonthDays().endtime, // 结束日期
  174. allocateNo: '', // 调拨单号
  175. creatorId: undefined, // 操作员id
  176. costTypeSn: undefined, // 费用类型
  177. allocateCategory: undefined, // 调拨类型1
  178. allocateTypeSn: undefined, // 调拨类型2
  179. bizUserSn: undefined, // 客服
  180. targetName: undefined, // 客户名称
  181. targetType: undefined// 客户类型
  182. },
  183. allocateTypeList: [], // 调拨类型
  184. allocateTypeVal: [], // 已选费用/调拨类型
  185. operatorList: [], // 操作员下拉数据
  186. totalData: null, // 合计
  187. rules: {
  188. 'time': [{ required: true, message: '请选择调拨开单日期', trigger: 'change' }]
  189. },
  190. disabled: false, // 查询、重置按钮是否可操作
  191. // 加载数据方法 必须为 Promise 对象
  192. loadData: parameter => {
  193. this.disabled = true
  194. const params = Object.assign(parameter, this.queryParam)
  195. delete params.time
  196. this.spinning = true
  197. // 获取列表数据 有分页
  198. return allocateReportList(params).then(res => {
  199. let data
  200. if (res.status == 200) {
  201. data = res.data
  202. // 总计
  203. this.getCount(params)
  204. // 计算表格序号
  205. const no = (data.pageNo - 1) * data.pageSize
  206. for (var i = 0; i < data.list.length; i++) {
  207. data.list[i].no = no + i + 1
  208. }
  209. this.disabled = false
  210. }
  211. this.spinning = false
  212. return data
  213. })
  214. }
  215. }
  216. },
  217. computed: {
  218. columns () {
  219. const _this = this
  220. const arr = [
  221. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  222. { title: '调拨单号', dataIndex: 'allocateNo', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  223. { title: '调拨开单日期', dataIndex: 'allocateDate', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  224. { title: '客户名称', dataIndex: 'targetName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  225. { title: '客户类型', dataIndex: 'targetTypeDictValue', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  226. { title: '费用类型', dataIndex: 'costTypeName', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  227. { title: '调拨类型', dataIndex: 'allocateSortName', width: '15%', align: 'center', scopedSlots: { customRender: 'allocateType' } },
  228. { title: '费用归属品牌', dataIndex: 'productBrandName', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  229. { title: '费用归属品类', dataIndex: 'productTypeName1', width: '15%', align: 'center', scopedSlots: { customRender: 'productType' } },
  230. { title: '调拨数量', dataIndex: 'totalQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  231. // { title: '成本价', dataIndex: 'totalCost', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  232. // { title: '毛利', dataIndex: 'totalGrossProfit', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  233. ]
  234. if (this.$hasPermissions('M_allocationOrderTotalList_salesPrice')) { // 成本价权限
  235. arr.push({ title: '售价', dataIndex: 'totalPrice', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  236. }
  237. if (this.$hasPermissions('M_allocationOrderTotalList_costPrice')) { // 成本价权限
  238. arr.push({ title: '成本价', dataIndex: 'totalCost', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  239. arr.push({ title: '毛利', dataIndex: 'totalGrossProfit', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  240. }
  241. arr.push({ title: '操作员', dataIndex: 'creatorName', width: '11%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true })
  242. return arr
  243. }
  244. },
  245. watch: {
  246. advanced (newValue, oldValue) {
  247. const _this = this
  248. this.$nextTick(() => { // 页面渲染完成后的回调
  249. _this.setTableH()
  250. })
  251. },
  252. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  253. this.setTableH()
  254. }
  255. },
  256. methods: {
  257. // 费用/调拨类型 change
  258. changeAllocatype (val, opts) {
  259. this.allocateTypeVal = val || []
  260. this.queryParam.costTypeSn = val && val[0] ? val[0] : ''
  261. this.queryParam.allocateCategory = val && val[1] ? val[1] : ''
  262. this.queryParam.allocateTypeSn = val && val[2] ? val[2] : ''
  263. },
  264. // 盘点库存日期
  265. handleStock () {
  266. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  267. },
  268. // 调拨开单日期 change
  269. dateChange (date) {
  270. if (date[0] && date[1]) {
  271. this.queryParam.time = date
  272. } else {
  273. this.queryParam.time = []
  274. }
  275. this.queryParam.beginDate = date[0] || ''
  276. this.queryParam.endDate = date[1] || ''
  277. },
  278. // 统计
  279. getCount (params) {
  280. allocateReportCount(params).then(res => {
  281. if (res.status == 200) {
  282. this.totalData = res.data
  283. } else {
  284. this.totalData = null
  285. }
  286. })
  287. },
  288. // 导出
  289. handleExport () {
  290. const _this = this
  291. const params = this.queryParam
  292. _this.spinning = true
  293. _this.exportLoading = true
  294. _this.$store.state.app.curActionPermission = 'B_allocationOrderTotalList_export'
  295. exportExcel(allocateReportExportExcel, params, '调拨开单报表', function () {
  296. _this.spinning = false
  297. _this.exportLoading = false
  298. _this.$store.state.app.curActionPermission = ''
  299. })
  300. },
  301. // 查询
  302. handleSearch () {
  303. const _this = this
  304. this.$refs.ruleForm.validate(valid => {
  305. if (valid) {
  306. _this.$refs.table.refresh(true)
  307. } else {
  308. _this.$message.error('请选择调拨开单日期')
  309. return false
  310. }
  311. })
  312. },
  313. // 重置
  314. resetSearchForm () {
  315. this.queryParam.time = [
  316. getDate.getCurrMonthDays().starttime,
  317. getDate.getCurrMonthDays().endtime
  318. ]
  319. this.$refs.rangeDate.resetDate(this.queryParam.time)
  320. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  321. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  322. this.queryParam.allocateNo = ''
  323. this.queryParam.creatorId = undefined
  324. this.queryParam.costTypeSn = undefined
  325. this.queryParam.allocateCategory = undefined
  326. this.queryParam.allocateTypeSn = undefined
  327. this.queryParam.bizUserSn = undefined
  328. this.queryParam.targetName = undefined
  329. this.queryParam.targetType = undefined
  330. this.allocateTypeVal = []
  331. this.$refs.ruleForm.resetFields()
  332. this.totalData = null
  333. this.$refs.table.clearTable()
  334. },
  335. // 调拨类型
  336. getAllocateTypeAllList () {
  337. allocateTypeAllList().then(res => {
  338. if (res.status == 200) {
  339. this.allocateTypeList = res.data
  340. } else {
  341. this.allocateTypeList = []
  342. }
  343. })
  344. },
  345. // 操作员
  346. getUserList () {
  347. userQueryList({}).then(res => {
  348. if (res.status == 200) {
  349. this.operatorList = res.data
  350. } else {
  351. this.operatorList = []
  352. }
  353. })
  354. },
  355. filterOption (input, option) {
  356. return (
  357. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  358. )
  359. },
  360. // 初始化
  361. pageInit () {
  362. const _this = this
  363. _this.getAllocateTypeAllList()
  364. _this.getUserList()
  365. this.$nextTick(() => {
  366. _this.setTableH()
  367. })
  368. },
  369. // 计算表格高度
  370. setTableH () {
  371. const tableSearchH = this.$refs.tableSearch.offsetHeight
  372. this.tableHeight = window.innerHeight - tableSearchH - 215
  373. }
  374. },
  375. mounted () {
  376. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  377. this.pageInit()
  378. this.resetSearchForm()
  379. }
  380. },
  381. activated () {
  382. // 如果是新页签打开,则重置当前页面
  383. if (this.$store.state.app.isNewTab) {
  384. this.pageInit()
  385. this.resetSearchForm()
  386. }
  387. },
  388. beforeRouteEnter (to, from, next) {
  389. next(vm => {})
  390. }
  391. }
  392. </script>