list.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model
  6. id="salesReturnReportList-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="导入类型">
  18. <a-select
  19. placeholder="请选择导入类型"
  20. v-model="queryParam.importType">
  21. <a-select-option value="STOCK_IMPORT">
  22. 库存导入
  23. </a-select-option>
  24. <a-select-option value="SPARE_PARTS_IMPORT">
  25. 散件导入
  26. </a-select-option>
  27. </a-select>
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-model-item label="导入时间">
  32. <rangeDate ref="rangeDate" @change="dateChange" />
  33. </a-form-model-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  36. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesReturnReportList-refresh">查询</a-button>
  37. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesReturnReportList-reset">重置</a-button>
  38. </a-col>
  39. </a-row>
  40. </a-form-model>
  41. </div>
  42. <!-- 合计 -->
  43. <a-alert type="info" style="margin-bottom:10px">
  44. <div class="ftext" slot="message">
  45. 总单数:<strong>{{ (totalData && (totalData.totalRowSize || totalData.totalRowSize==0)) ? totalData.totalRowSize : '--' }}</strong>;
  46. 产品总数量:<strong>{{ (totalData && (totalData.productTotalQty || totalData.productTotalQty==0)) ? totalData.productTotalQty : '--' }}</strong>;
  47. <div v-if="$hasPermissions('M_ShowAllCost')" style="display: inline-block;">
  48. 总成本:<strong>{{ (totalData && (totalData.productTotalCost || totalData.productTotalCost==0)) ? '¥'+totalData.productTotalCost : '--' }}</strong>。
  49. </div>
  50. </div>
  51. </a-alert>
  52. <!-- 列表 -->
  53. <s-table
  54. class="sTable"
  55. ref="table"
  56. size="small"
  57. :rowKey="(record) => record.id"
  58. :columns="columns"
  59. :data="loadData"
  60. :defaultLoadData="false"
  61. bordered>
  62. </s-table>
  63. </a-spin>
  64. </template>
  65. <script>
  66. import { commonMixin } from '@/utils/mixin'
  67. import { STable, VSelect } from '@/components'
  68. import rangeDate from '@/views/common/rangeDate.vue'
  69. import { reportStockImportList, reportStockImportCount } from '@/api/reportData'
  70. export default {
  71. components: { STable, VSelect, rangeDate },
  72. mixins: [commonMixin],
  73. data () {
  74. return {
  75. spinning: false,
  76. labelCol: { span: 8 },
  77. wrapperCol: { span: 16 },
  78. advanced: false, // 高级搜索 展开/关闭
  79. tableHeight: 0,
  80. queryParam: { // 查询条件
  81. time: [],
  82. beginDate: '',
  83. endDate: '',
  84. importType: undefined
  85. },
  86. rules: {
  87. 'time': [{ required: true, message: '请选择导入时间', trigger: 'change' }]
  88. },
  89. disabled: false, // 查询、重置按钮是否可操作
  90. exportLoading: false,
  91. // 加载数据方法 必须为 Promise 对象
  92. loadData: parameter => {
  93. this.disabled = true
  94. const params = Object.assign(parameter, this.queryParam)
  95. this.spinning = true
  96. delete params.time
  97. return reportStockImportList(params).then(res => {
  98. let data
  99. if (res.status == 200) {
  100. data = res.data
  101. // 总计
  102. this.getCount(params)
  103. const no = (data.pageNo - 1) * data.pageSize
  104. for (var i = 0; i < data.list.length; i++) {
  105. data.list[i].no = no + i + 1
  106. }
  107. this.disabled = false
  108. }
  109. this.spinning = false
  110. return data
  111. })
  112. },
  113. totalData: null // 合计
  114. }
  115. },
  116. computed: {
  117. columns () {
  118. const arr = [
  119. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  120. { title: '库存导入单号', dataIndex: 'stockImportNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  121. { title: '导入类型', dataIndex: 'importTypeDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  122. { title: '款数', dataIndex: 'productTotalCategory', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  123. { title: '数量', dataIndex: 'productTotalQty', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  124. // { title: '成本', dataIndex: 'totalCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  125. { title: '导入时间', dataIndex: 'importTime', width: '15%', align: 'center', customRender: function (text) { return text || '--' } }
  126. ]
  127. if (this.$hasPermissions('M_ShowAllCost')) {
  128. arr.splice(5, 0, { title: '成本', dataIndex: 'productTotalCost', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  129. }
  130. return arr
  131. }
  132. },
  133. methods: {
  134. // 合计
  135. getCount (params) {
  136. reportStockImportCount(params).then(res => {
  137. if (res.status == 200) {
  138. this.totalData = res.data
  139. } else {
  140. this.totalData = null
  141. }
  142. })
  143. },
  144. // 创建时间 change
  145. dateChange (date) {
  146. this.queryParam.time = date
  147. this.queryParam.beginDate = date[0] || ''
  148. this.queryParam.endDate = date[1] || ''
  149. },
  150. // 查询
  151. handleSearch () {
  152. this.$refs.ruleForm.validate(valid => {
  153. if (valid) {
  154. this.$refs.table.refresh(true)
  155. } else {
  156. console.log('error submit!!')
  157. return false
  158. }
  159. })
  160. },
  161. // 重置
  162. resetSearchForm () {
  163. this.queryParam.time = []
  164. this.queryParam.beginDate = ''
  165. this.queryParam.endDate = ''
  166. this.queryParam.importType = undefined
  167. this.$refs.ruleForm.resetFields()
  168. this.totalData = null
  169. this.$refs.table.clearTable()
  170. this.$nextTick(() => {
  171. this.$refs.rangeDate.resetDate()
  172. })
  173. },
  174. pageInit () {}
  175. },
  176. mounted () {
  177. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  178. this.pageInit()
  179. this.resetSearchForm()
  180. }
  181. },
  182. activated () {
  183. // 如果是新页签打开,则重置当前页面
  184. if (this.$store.state.app.isNewTab) {
  185. this.pageInit()
  186. this.resetSearchForm()
  187. }
  188. },
  189. beforeRouteEnter (to, from, next) {
  190. next(vm => {})
  191. }
  192. }
  193. </script>