list.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <a-card size="small" :bordered="false" class="allocationOrderTotalList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="allocationOrderTotalList-form"
  8. ref="ruleForm"
  9. :model="queryParam"
  10. :rules="rules"
  11. :labelCol="labelCol"
  12. :wrapperCol="wrapperCol"
  13. @keyup.enter.native="handleSearch" >
  14. <a-row :gutter="15">
  15. <a-col :md="7" :sm="24">
  16. <a-form-model-item label="调拨开单日期" prop="time">
  17. <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="5" :sm="24">
  21. <a-form-model-item label="调拨单号">
  22. <a-input id="allocationOrderTotalList-allocateNo" v-model.trim="queryParam.allocateNo" allowClear placeholder="请输入调拨单号"/>
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="5" :sm="24">
  26. <a-form-model-item label="操作员">
  27. <a-select id="allocationOrderTotalList-creatorId" v-model="queryParam.creatorId" placeholder="请选择操作员" allowClear >
  28. <a-select-option v-for="item in operatorList" :key="item.sn" :value="item.sn">{{ item.name }}</a-select-option>
  29. </a-select>
  30. </a-form-model-item>
  31. </a-col>
  32. <template v-if="advanced">
  33. <a-col :md="6" :sm="24">
  34. <a-form-model-item label="调拨类别">
  35. <v-select code="ALLOCATE_CATEGORY" id="allocationOrderTotalList-allocateCategory" v-model="queryParam.allocateCategory" allowClear placeholder="请选择调拨类别"></v-select>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-model-item label="调拨类型名称">
  40. <a-select id="allocationOrderTotalList-allocateTypeSn" v-model="queryParam.allocateTypeSn" placeholder="请选择调拨类型名称" allowClear >
  41. <a-select-option v-for="item in allocateTypeList" :key="item.allocateTypeSn" :value="item.allocateTypeSn">{{ item.name }}</a-select-option>
  42. </a-select>
  43. </a-form-model-item>
  44. </a-col>
  45. </template>
  46. <a-col :md="7" :sm="24" style="margin-top: 3px;">
  47. <a-button
  48. style="margin-bottom: 18px;"
  49. type="primary"
  50. class="button-warning"
  51. size="small"
  52. @click="handleStock"
  53. id="allocationOrderTotalList-stockDate">盘点区间日期</a-button>
  54. <a-button style="margin: 0 0 18px 8px" type="primary" @click="handleSearch" :disabled="disabled" id="allocationOrderTotalList-refresh">查询</a-button>
  55. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="allocationOrderTotalList-reset">重置</a-button>
  56. <a @click="advanced=!advanced" style="margin-left: 8px">
  57. {{ advanced ? '收起' : '展开' }}
  58. <a-icon :type="advanced ? 'up' : 'down'"/>
  59. </a>
  60. </a-col>
  61. </a-row>
  62. </a-form-model>
  63. </div>
  64. <!-- 列表 -->
  65. <s-table
  66. class="sTable"
  67. ref="table"
  68. size="small"
  69. :rowKey="(record) => record.id"
  70. :columns="columns"
  71. :data="loadData"
  72. :defaultLoadData="false"
  73. :scroll="{ x: 1140 }"
  74. bordered>
  75. <template slot="footer" slot-scope="currentPageData">
  76. <a-row :gutter="15">
  77. <a-col :md="4" :sm="24">
  78. 总数量:{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}
  79. </a-col>
  80. <a-col :md="4" :sm="24">
  81. 总成本价:{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? totalData.totalCost : '--' }}
  82. </a-col>
  83. <a-col :md="4" :sm="24">
  84. 总毛利:{{ (totalData && (totalData.totalGrossProfit || totalData.totalGrossProfit==0)) ? totalData.totalGrossProfit : '--' }}
  85. </a-col>
  86. </a-row>
  87. </template>
  88. </s-table>
  89. </a-spin>
  90. </a-card>
  91. </template>
  92. <script>
  93. import { STable, VSelect } from '@/components'
  94. import rangeDate from '@/views/common/rangeDate.vue'
  95. import { allocateTypeAllList } from '@/api/allocateType'
  96. import { userQueryList } from '@/api/power-user'
  97. import { allocateReportList, allocateReportCount } from '@/api/allocateReport'
  98. export default {
  99. components: { STable, VSelect, rangeDate },
  100. data () {
  101. return {
  102. spinning: false,
  103. advanced: false, // 高级搜索 展开/关闭
  104. queryParam: { // 查询条件
  105. time: [],
  106. beginDate: '',
  107. endDate: '',
  108. allocateNo: '',
  109. creatorId: undefined,
  110. allocateCategory: undefined,
  111. allocateTypeSn: undefined
  112. },
  113. labelCol: { span: 8 },
  114. wrapperCol: { span: 16 },
  115. rules: {
  116. 'time': [{ required: true, message: '请选择调拨开单日期', trigger: 'change' }]
  117. },
  118. disabled: false, // 查询、重置按钮是否可操作
  119. columns: [
  120. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  121. { title: '调拨单号', dataIndex: 'allocateNo', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  122. { title: '调拨开单日期', dataIndex: 'allocateDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  123. { title: '客户名称', dataIndex: 'targetName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  124. { title: '调拨数量', dataIndex: 'totalQty', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  125. { title: '成本价', dataIndex: 'totalCost', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  126. { title: '毛利', dataIndex: 'grossProfit', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  127. { title: '操作员', dataIndex: 'creatorName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  128. ],
  129. // 加载数据方法 必须为 Promise 对象
  130. loadData: parameter => {
  131. this.disabled = true
  132. const params = Object.assign(parameter, this.queryParam)
  133. delete params.time
  134. this.spinning = true
  135. return allocateReportList(params).then(res => {
  136. // 总计
  137. this.getCount(params)
  138. const data = res.data
  139. const no = (data.pageNo - 1) * data.pageSize
  140. for (var i = 0; i < data.list.length; i++) {
  141. data.list[i].no = no + i + 1
  142. }
  143. this.disabled = false
  144. this.spinning = false
  145. return data
  146. })
  147. },
  148. allocateTypeList: [], // 调拨类型
  149. operatorList: [], // 操作员下拉数据
  150. totalData: null // 合计
  151. }
  152. },
  153. methods: {
  154. // 盘点库存日期
  155. handleStock () {
  156. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  157. },
  158. // 创建时间 change
  159. dateChange (date) {
  160. if (date.length) {
  161. if (date[0] == '' && date[1] == '') {
  162. this.resetSearchForm()
  163. } else {
  164. this.queryParam.time = date
  165. }
  166. }
  167. this.queryParam.beginDate = date[0]
  168. this.queryParam.endDate = date[1]
  169. },
  170. // 合计
  171. getCount (params) {
  172. allocateReportCount(params).then(res => {
  173. if (res.status == 200) {
  174. this.totalData = res.data
  175. } else {
  176. this.totalData = null
  177. }
  178. })
  179. },
  180. // 查询
  181. handleSearch () {
  182. const _this = this
  183. this.$refs.ruleForm.validate(valid => {
  184. if (valid) {
  185. _this.$refs.table.refresh(true)
  186. } else {
  187. console.log('error submit!!')
  188. return false
  189. }
  190. })
  191. },
  192. // 重置
  193. resetSearchForm () {
  194. this.$refs.rangeDate.resetDate()
  195. this.queryParam.time = []
  196. this.queryParam.beginDate = ''
  197. this.queryParam.endDate = ''
  198. this.queryParam.allocateNo = ''
  199. this.queryParam.creatorId = undefined
  200. this.queryParam.allocateCategory = undefined
  201. this.queryParam.allocateTypeSn = undefined
  202. this.$refs.ruleForm.resetFields()
  203. this.totalData = null
  204. this.$refs.table.clearTable()
  205. },
  206. // 调拨类型
  207. getAllocateTypeAllList () {
  208. allocateTypeAllList().then(res => {
  209. if (res.status == 200) {
  210. this.allocateTypeList = res.data
  211. } else {
  212. this.allocateTypeList = []
  213. }
  214. })
  215. },
  216. // 操作员
  217. getUserList () {
  218. userQueryList({}).then(res => {
  219. if (res.status == 200) {
  220. this.operatorList = res.data
  221. } else {
  222. this.operatorList = []
  223. }
  224. })
  225. }
  226. },
  227. beforeRouteEnter (to, from, next) {
  228. next(vm => {
  229. vm.getAllocateTypeAllList()
  230. vm.getUserList()
  231. })
  232. }
  233. }
  234. </script>