list.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model
  6. id="urgentItemsOffsetReport-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :model="queryParam"
  11. :rules="rules"
  12. :labelCol="labelCol"
  13. :wrapperCol="wrapperCol"
  14. @keyup.enter.native="handleSearch" >
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-model-item label="冲减时间" prop="time">
  18. <rangeDate ref="rangeDate" @change="dateChange" />
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-item label="急件单号">
  23. <a-input id="urgentItemsOffsetReport-urgentBillNo" v-model.trim="queryParam.urgentBillNo" allowClear placeholder="请输入急件单号"/>
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="6" :sm="24">
  27. <a-form-item label="关联单号">
  28. <a-input id="urgentItemsOffsetReport-bizBillNo" v-model.trim="queryParam.bizBillNo" allowClear placeholder="请输入销售单号"/>
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md="6" :sm="24">
  32. <a-form-model-item label="客户名称">
  33. <custList id="urgentItemsOffsetReport-buyerName" ref="custSatelliteList" @change="custSatelliteChange"></custList>
  34. </a-form-model-item>
  35. </a-col>
  36. <!-- <a-col :md="6" :sm="24">
  37. <a-form-item label="单据来源">
  38. <v-select
  39. v-model="queryParam.sourceType"
  40. ref="sourceType"
  41. id="urgentItemsOffsetReport-sourceType"
  42. code="SALES_SOURCE"
  43. placeholder="请选择单据来源"
  44. allowClear></v-select>
  45. </a-form-item>
  46. </a-col> -->
  47. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  48. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="urgentItemsOffsetReport-refresh">查询</a-button>
  49. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="urgentItemsOffsetReport-reset">重置</a-button>
  50. <a-button
  51. type="primary"
  52. style="margin-left: 5px"
  53. @click="handleExport"
  54. :disabled="disabled"
  55. :loading="exportLoading"
  56. class="button-warning"
  57. v-if="$hasPermissions('M_urgentItemsOffsetReportExport')"
  58. id="urgentItemsOffsetReport-export-btn">导出</a-button>
  59. </a-col>
  60. </a-row>
  61. </a-form-model>
  62. </div>
  63. <!-- 合计 -->
  64. <a-alert type="info" style="margin-bottom:10px">
  65. <div class="ftext" slot="message">
  66. 总单数:<strong>{{ basiceNum?basiceNum:'--' }}</strong>;
  67. 产品总数量:<strong>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</strong>;
  68. <div v-if="$hasPermissions('M_ShowAllCost')" style="display: inline-block;">
  69. 冲减总成本:<strong>{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? toThousands(totalData.totalCost) : '--' }}</strong>。
  70. </div>
  71. </div>
  72. </a-alert>
  73. <!-- 列表 -->
  74. <s-table
  75. class="sTable"
  76. ref="table"
  77. size="small"
  78. :rowKey="(record) => record.id"
  79. :columns="columns"
  80. :data="loadData"
  81. :defaultLoadData="false"
  82. bordered>
  83. </s-table>
  84. </a-spin>
  85. </template>
  86. <script>
  87. import { commonMixin } from '@/utils/mixin'
  88. import { STable, VSelect } from '@/components'
  89. import rangeDate from '@/views/common/rangeDate.vue'
  90. import { downloadExcel } from '@/libs/JGPrint.js'
  91. import custList from '@/views/common/custList.vue'
  92. import { reportUrgentPageList, reportUrgentQueryCount, reportUrgentExport } from '@/api/reportData'
  93. export default {
  94. components: { STable, VSelect, rangeDate, custList },
  95. mixins: [commonMixin],
  96. data () {
  97. return {
  98. spinning: false,
  99. labelCol: { span: 8 },
  100. wrapperCol: { span: 16 },
  101. advanced: false, // 高级搜索 展开/关闭
  102. tableHeight: 0,
  103. queryParam: { // 查询条件
  104. time: [],
  105. beginDate: '',
  106. endDate: '',
  107. buyerNameCurrent: undefined, // 客户名称
  108. buyerSnCurrent: undefined, // 客户sn
  109. bizBillNo: '',
  110. urgentBillNo: '',
  111. sourceType: undefined
  112. },
  113. rules: {
  114. 'time': [{ required: true, message: '请选择冲减时间', trigger: 'change' }]
  115. },
  116. disabled: false, // 查询、重置按钮是否可操作
  117. basiceNum: null, // 列表数据
  118. exportLoading: false,
  119. // 加载数据方法 必须为 Promise 对象
  120. loadData: parameter => {
  121. this.disabled = true
  122. const params = Object.assign(parameter, this.queryParam)
  123. this.spinning = true
  124. delete params.time
  125. return reportUrgentPageList(params).then(res => {
  126. let data
  127. if (res.status == 200) {
  128. data = res.data
  129. // 总计
  130. this.getCount(params)
  131. const no = (data.pageNo - 1) * data.pageSize
  132. for (var i = 0; i < data.list.length; i++) {
  133. data.list[i].no = no + i + 1
  134. }
  135. this.disabled = false
  136. }
  137. this.spinning = false
  138. this.basiceNum = data.count
  139. return data
  140. })
  141. },
  142. totalData: null // 合计
  143. }
  144. },
  145. computed: {
  146. columns () {
  147. const _this = this
  148. const arr = [
  149. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  150. { title: '急件单号', dataIndex: 'urgentBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  151. { title: '销售单号', dataIndex: 'bizBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  152. // { title: '单据来源', dataIndex: 'sourceTypeDictValue', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  153. { title: '客户名称', dataIndex: 'buyerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  154. { title: '款数', dataIndex: 'totalCategory', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  155. { title: '数量', dataIndex: 'totalQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  156. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  157. { title: '冲减时间', dataIndex: 'offSetTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } }
  158. ]
  159. if (this.$hasPermissions('M_ShowAllCost')) {
  160. arr.splice(6, 0, { title: '成本', dataIndex: 'totalCost', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  161. }
  162. return arr
  163. }
  164. },
  165. methods: {
  166. // 合计
  167. getCount (params) {
  168. reportUrgentQueryCount(params).then(res => {
  169. if (res.status == 200) {
  170. this.totalData = res.data
  171. } else {
  172. this.totalData = null
  173. }
  174. })
  175. },
  176. // 创建时间 change
  177. dateChange (date) {
  178. this.queryParam.time = date
  179. this.queryParam.beginDate = date[0] || ''
  180. this.queryParam.endDate = date[1] || ''
  181. },
  182. // 查询
  183. handleSearch () {
  184. this.$refs.ruleForm.validate(valid => {
  185. if (valid) {
  186. this.$refs.table.refresh(true)
  187. } else {
  188. console.log('error submit!!')
  189. return false
  190. }
  191. })
  192. },
  193. custSatelliteChange (v, row) {
  194. if (row && row.customerSn) {
  195. this.queryParam.buyerSnCurrent = row.customerSn
  196. this.queryParam.buyerNameCurrent = undefined
  197. } else {
  198. this.queryParam.buyerNameCurrent = v
  199. this.queryParam.buyerSnCurrent = undefined
  200. }
  201. },
  202. // 重置
  203. resetSearchForm () {
  204. this.queryParam = {
  205. time: [],
  206. beginDate: '',
  207. endDate: '',
  208. buyerNameCurrent: undefined,
  209. buyerSnCurrent: undefined,
  210. bizBillNo: '',
  211. urgentBillNo: '',
  212. sourceType: undefined
  213. }
  214. this.$refs.custSatelliteList.resetForm()
  215. this.$refs.rangeDate.resetDate()
  216. this.$refs.ruleForm.resetFields()
  217. this.totalData = null
  218. this.basiceNum = null
  219. this.$refs.table.clearTable()
  220. },
  221. // 导出
  222. handleExport () {
  223. const _this = this
  224. this.$refs.ruleForm.validate(valid => {
  225. if (valid) {
  226. const params = _this.queryParam
  227. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  228. _this.exportLoading = true
  229. _this.spinning = true
  230. reportUrgentExport(params).then(res => {
  231. downloadExcel(res, '急件冲减报表')
  232. _this.exportLoading = false
  233. _this.spinning = false
  234. })
  235. } else {
  236. console.log('error submit!!')
  237. return false
  238. }
  239. })
  240. },
  241. pageInit () {}
  242. },
  243. mounted () {
  244. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  245. this.pageInit()
  246. this.resetSearchForm()
  247. }
  248. },
  249. activated () {
  250. // 如果是新页签打开,则重置当前页面
  251. if (this.$store.state.app.isNewTab) {
  252. this.pageInit()
  253. this.resetSearchForm()
  254. }
  255. },
  256. beforeRouteEnter (to, from, next) {
  257. next(vm => {})
  258. }
  259. }
  260. </script>