list.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. <a-input id="urgentItemsOffsetReport-buyerName" v-model.trim="queryParam.buyerName" allowClear placeholder="请输入客户名称"/>
  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 { reportUrgentPageList, reportUrgentQueryCount, reportUrgentExport } from '@/api/reportData'
  92. export default {
  93. components: { STable, VSelect, rangeDate },
  94. mixins: [commonMixin],
  95. data () {
  96. return {
  97. spinning: false,
  98. labelCol: { span: 8 },
  99. wrapperCol: { span: 16 },
  100. advanced: false, // 高级搜索 展开/关闭
  101. tableHeight: 0,
  102. queryParam: { // 查询条件
  103. time: [],
  104. beginDate: '',
  105. endDate: '',
  106. buyerName: '',
  107. bizBillNo: '',
  108. urgentBillNo: '',
  109. sourceType: undefined
  110. },
  111. rules: {
  112. 'time': [{ required: true, message: '请选择冲减时间', trigger: 'change' }]
  113. },
  114. disabled: false, // 查询、重置按钮是否可操作
  115. basiceNum:null,//列表数据
  116. exportLoading: false,
  117. // 加载数据方法 必须为 Promise 对象
  118. loadData: parameter => {
  119. this.disabled = true
  120. const params = Object.assign(parameter, this.queryParam)
  121. this.spinning = true
  122. delete params.time
  123. return reportUrgentPageList(params).then(res => {
  124. let data
  125. if (res.status == 200) {
  126. data = res.data
  127. // 总计
  128. this.getCount(params)
  129. const no = (data.pageNo - 1) * data.pageSize
  130. for (var i = 0; i < data.list.length; i++) {
  131. data.list[i].no = no + i + 1
  132. }
  133. this.disabled = false
  134. }
  135. this.spinning = false
  136. this.basiceNum=data.count
  137. return data
  138. })
  139. },
  140. totalData: null // 合计
  141. }
  142. },
  143. computed: {
  144. columns () {
  145. const _this = this
  146. const arr = [
  147. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  148. { title: '急件单号', dataIndex: 'urgentBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '销售单号', dataIndex: 'bizBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  150. { title: '单据来源', dataIndex: 'sourceTypeDictValue', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  151. { title: '客户名称', dataIndex: 'buyerName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  152. { title: '款数', dataIndex: 'totalCategory', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  153. { title: '数量', dataIndex: 'totalQty', width: '9%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  154. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  155. { title: '冲减时间', dataIndex: 'offSetTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } }
  156. ]
  157. if (this.$hasPermissions('M_ShowAllCost')) {
  158. arr.splice(7, 0, { title: '成本', dataIndex: 'totalCost', width: '9%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  159. }
  160. return arr
  161. }
  162. },
  163. methods: {
  164. // 合计
  165. getCount (params) {
  166. reportUrgentQueryCount(params).then(res => {
  167. if (res.status == 200) {
  168. this.totalData = res.data
  169. } else {
  170. this.totalData = null
  171. }
  172. })
  173. },
  174. // 创建时间 change
  175. dateChange (date) {
  176. this.queryParam.time = date
  177. this.queryParam.beginDate = date[0] || ''
  178. this.queryParam.endDate = date[1] || ''
  179. },
  180. // 查询
  181. handleSearch () {
  182. this.$refs.ruleForm.validate(valid => {
  183. if (valid) {
  184. this.$refs.table.refresh(true)
  185. } else {
  186. console.log('error submit!!')
  187. return false
  188. }
  189. })
  190. },
  191. // 重置
  192. resetSearchForm () {
  193. this.queryParam = {
  194. time: [],
  195. beginDate: '',
  196. endDate: '',
  197. buyerName: '',
  198. bizBillNo: '',
  199. urgentBillNo: '',
  200. sourceType: undefined
  201. }
  202. this.$refs.rangeDate.resetDate()
  203. this.$refs.ruleForm.resetFields()
  204. this.totalData = null
  205. this.basiceNum = null
  206. this.$refs.table.clearTable()
  207. },
  208. // 导出
  209. handleExport () {
  210. const _this = this
  211. this.$refs.ruleForm.validate(valid => {
  212. if (valid) {
  213. const params = _this.queryParam
  214. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  215. _this.exportLoading = true
  216. _this.spinning = true
  217. reportUrgentExport(params).then(res => {
  218. downloadExcel(res, '急件冲减报表')
  219. _this.exportLoading = false
  220. _this.spinning = false
  221. })
  222. } else {
  223. console.log('error submit!!')
  224. return false
  225. }
  226. })
  227. },
  228. pageInit () {}
  229. },
  230. mounted () {
  231. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  232. this.pageInit()
  233. this.resetSearchForm()
  234. }
  235. },
  236. activated () {
  237. // 如果是新页签打开,则重置当前页面
  238. if (this.$store.state.app.isNewTab) {
  239. this.pageInit()
  240. this.resetSearchForm()
  241. }
  242. },
  243. beforeRouteEnter (to, from, next) {
  244. next(vm => {})
  245. }
  246. }
  247. </script>