list.vue 7.2 KB

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