list.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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>{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</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. exportLoading: false,
  116. // 加载数据方法 必须为 Promise 对象
  117. loadData: parameter => {
  118. this.disabled = true
  119. const params = Object.assign(parameter, this.queryParam)
  120. this.spinning = true
  121. delete params.time
  122. return reportUrgentPageList(params).then(res => {
  123. let data
  124. if (res.status == 200) {
  125. data = res.data
  126. // 总计
  127. this.getCount(params)
  128. const no = (data.pageNo - 1) * data.pageSize
  129. for (var i = 0; i < data.list.length; i++) {
  130. data.list[i].no = no + i + 1
  131. }
  132. this.disabled = false
  133. }
  134. this.spinning = false
  135. return data
  136. })
  137. },
  138. totalData: null // 合计
  139. }
  140. },
  141. computed: {
  142. columns () {
  143. const _this = this
  144. const arr = [
  145. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  146. { title: '急件单号', dataIndex: 'urgentBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '销售单号', dataIndex: 'bizBillNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  148. // { title: '单据来源', dataIndex: 'sourceTypeDictValue', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '客户名称', dataIndex: 'buyerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  150. { title: '款数', dataIndex: 'totalCategory', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  151. { title: '数量', dataIndex: 'totalQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  152. // { title: '成本', dataIndex: 'totalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  153. { title: '冲减时间', dataIndex: 'offSetTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } }
  154. ]
  155. if (this.$hasPermissions('M_ShowAllCost')) {
  156. arr.splice(7, 0, { title: '成本', dataIndex: 'totalCost', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  157. }
  158. return arr
  159. }
  160. },
  161. methods: {
  162. // 合计
  163. getCount (params) {
  164. reportUrgentQueryCount(params).then(res => {
  165. if (res.status == 200) {
  166. this.totalData = res.data
  167. } else {
  168. this.totalData = null
  169. }
  170. })
  171. },
  172. // 创建时间 change
  173. dateChange (date) {
  174. this.queryParam.time = date
  175. this.queryParam.beginDate = date[0] || ''
  176. this.queryParam.endDate = date[1] || ''
  177. },
  178. // 查询
  179. handleSearch () {
  180. this.$refs.ruleForm.validate(valid => {
  181. if (valid) {
  182. this.$refs.table.refresh(true)
  183. } else {
  184. console.log('error submit!!')
  185. return false
  186. }
  187. })
  188. },
  189. // 重置
  190. resetSearchForm () {
  191. this.queryParam = {
  192. time: [],
  193. beginDate: '',
  194. endDate: '',
  195. buyerName: '',
  196. bizBillNo: '',
  197. urgentBillNo: '',
  198. sourceType: undefined
  199. }
  200. this.$refs.rangeDate.resetDate()
  201. this.$refs.ruleForm.resetFields()
  202. this.totalData = null
  203. this.$refs.table.clearTable()
  204. },
  205. // 导出
  206. handleExport () {
  207. const _this = this
  208. this.$refs.ruleForm.validate(valid => {
  209. if (valid) {
  210. const params = _this.queryParam
  211. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  212. _this.exportLoading = true
  213. _this.spinning = true
  214. reportUrgentExport(params).then(res => {
  215. downloadExcel(res, '急件冲减报表')
  216. _this.exportLoading = false
  217. _this.spinning = false
  218. })
  219. } else {
  220. console.log('error submit!!')
  221. return false
  222. }
  223. })
  224. },
  225. pageInit () {}
  226. },
  227. mounted () {
  228. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  229. this.pageInit()
  230. this.resetSearchForm()
  231. }
  232. },
  233. activated () {
  234. // 如果是新页签打开,则重置当前页面
  235. if (this.$store.state.app.isNewTab) {
  236. this.pageInit()
  237. this.resetSearchForm()
  238. }
  239. },
  240. beforeRouteEnter (to, from, next) {
  241. next(vm => {})
  242. }
  243. }
  244. </script>