detailList.vue 12 KB

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