list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="allocationOrderTotalList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="allocationOrderTotalList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. :labelCol="labelCol"
  14. :wrapperCol="wrapperCol"
  15. @keyup.enter.native="handleSearch" >
  16. <a-row :gutter="15">
  17. <a-col :md="6" :sm="24">
  18. <a-form-model-item label="调拨开单日期" prop="time">
  19. <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-model-item label="调拨单号">
  24. <a-input id="allocationOrderTotalList-allocateNo" v-model.trim="queryParam.allocateNo" allowClear placeholder="请输入调拨单号"/>
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-model-item label="操作员">
  29. <a-select
  30. id="allocationOrderTotalList-creatorId"
  31. allowClear
  32. v-model="queryParam.creatorId"
  33. placeholder="请选择操作员"
  34. :showSearch="true"
  35. option-filter-prop="children"
  36. :filter-option="filterOption">
  37. <a-select-option v-for="item in operatorList" :key="item.sn" :value="item.sn">{{ item.name }}</a-select-option>
  38. </a-select>
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :md="6" :sm="24">
  42. <a-form-model-item label="费用/调拨类型">
  43. <AllocateType id="allocationDetailsList-allocateTypeSn" v-model="allocateTypeVal" :changeOnSelect="true" placeholder="请选择费用/调拨类型" @change="changeAllocatype"></AllocateType>
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :md="24" :sm="24" style="margin-bottom: 10px;text-align:center;">
  47. <!-- <a-button
  48. type="primary"
  49. class="button-info"
  50. size="small"
  51. @click="handleStock"
  52. id="allocationOrderTotalList-stockDate">盘点区间日期</a-button> -->
  53. <a-button style="margin-left: 5px" type="primary" @click="handleSearch" :disabled="disabled" id="allocationOrderTotalList-refresh">查询</a-button>
  54. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="allocationOrderTotalList-reset">重置</a-button>
  55. </a-col>
  56. </a-row>
  57. </a-form-model>
  58. </div>
  59. </a-card>
  60. <!-- 列表 -->
  61. <a-card size="small" :bordered="false">
  62. <a-spin :spinning="spinning" tip="Loading...">
  63. <s-table
  64. class="sTable fixPagination"
  65. ref="table"
  66. size="small"
  67. :rowKey="(record) => record.id"
  68. :columns="columns"
  69. :data="loadData"
  70. :defaultLoadData="false"
  71. bordered
  72. :style="{ height: tableHeight+84.5+'px' }"
  73. :scroll="{ y: tableHeight - 20 }">
  74. <template slot="footer">
  75. <table>
  76. <tr>
  77. <td style="width:15%"></td>
  78. <td style="width:15%"></td>
  79. <td style="width:20%"></td>
  80. <td style="width:12%;text-align: center;">总数量:{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? totalData.totalQty : '--' }}</td>
  81. <td style="width:12%;text-align: right;"><span v-if="$hasPermissions('M_allocationOrderTotalList_costPrice')">总成本价:{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? toThousands(totalData.totalCost) : '--' }}</span></td>
  82. <td style="width:12%;text-align: right;"><span v-if="$hasPermissions('M_allocationOrderTotalList_costPrice')">总毛利:{{ (totalData && (totalData.totalGrossProfit || totalData.totalGrossProfit==0)) ? toThousands(totalData.totalGrossProfit) : '--' }}</span></td>
  83. <td style="width:14%"></td>
  84. </tr>
  85. </table>
  86. </template>
  87. </s-table>
  88. </a-spin>
  89. </a-card>
  90. </div>
  91. </template>
  92. <script>
  93. import { commonMixin } from '@/utils/mixin'
  94. import getDate from '@/libs/getDate.js'
  95. import { STable, VSelect } from '@/components'
  96. import rangeDate from '@/views/common/rangeDate.vue'
  97. import { allocateTypeAllList } from '@/api/allocateType'
  98. import { userQueryList } from '@/api/power-user'
  99. import AllocateType from '@/views/common/allocateType.js'
  100. import { allocateReportList, allocateReportCount } from '@/api/allocateReport'
  101. export default {
  102. name: 'AllocationOrderTotalList',
  103. mixins: [commonMixin],
  104. components: { STable, VSelect, rangeDate, AllocateType },
  105. data () {
  106. return {
  107. spinning: false,
  108. allocateTypeVal: [],
  109. queryParam: { // 查询条件
  110. time: [
  111. getDate.getCurrMonthDays().starttime,
  112. getDate.getCurrMonthDays().endtime
  113. ],
  114. beginDate: getDate.getCurrMonthDays().starttime,
  115. endDate: getDate.getCurrMonthDays().endtime,
  116. allocateNo: '',
  117. creatorId: undefined,
  118. costTypeSn: undefined, // 费用类型
  119. allocateCategory: undefined, // 调拨类型1
  120. allocateTypeSn: undefined // 调拨类型2
  121. },
  122. labelCol: { span: 8 },
  123. wrapperCol: { span: 16 },
  124. rules: {
  125. 'time': [{ required: true, message: '请选择调拨开单日期', trigger: 'change' }]
  126. },
  127. disabled: false, // 查询、重置按钮是否可操作
  128. // 加载数据方法 必须为 Promise 对象
  129. loadData: parameter => {
  130. this.disabled = true
  131. const params = Object.assign(parameter, this.queryParam)
  132. delete params.time
  133. this.spinning = true
  134. return allocateReportList(params).then(res => {
  135. let data
  136. if (res.status == 200) {
  137. data = res.data
  138. // 总计
  139. this.getCount(params)
  140. const no = (data.pageNo - 1) * data.pageSize
  141. for (var i = 0; i < data.list.length; i++) {
  142. data.list[i].no = no + i + 1
  143. }
  144. this.disabled = false
  145. }
  146. this.spinning = false
  147. return data
  148. })
  149. },
  150. allocateTypeList: [], // 调拨类型
  151. operatorList: [], // 操作员下拉数据
  152. totalData: null, // 合计
  153. tableHeight: 0
  154. }
  155. },
  156. computed: {
  157. columns () {
  158. const _this = this
  159. const arr = [
  160. { title: '调拨单号', dataIndex: 'allocateNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  161. { title: '调拨开单日期', dataIndex: 'allocateDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  162. { title: '客户名称', dataIndex: 'targetName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  163. { title: '调拨数量', dataIndex: 'totalQty', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  164. // { title: '成本价', dataIndex: 'totalCost', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  165. // { title: '毛利', dataIndex: 'totalGrossProfit', width: '12%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  166. { title: '操作员', dataIndex: 'creatorName', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true }
  167. ]
  168. if (this.$hasPermissions('M_allocationOrderTotalList_costPrice')) { // 成本价权限
  169. arr.splice(4, 0, { title: '成本价', dataIndex: 'totalCost', width: '12%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  170. arr.splice(5, 0, { title: '毛利', dataIndex: 'totalGrossProfit', width: '12%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  171. }
  172. return arr
  173. }
  174. },
  175. methods: {
  176. changeAllocatype (val, opts) {
  177. this.allocateTypeVal = val || []
  178. this.queryParam.costTypeSn = val && val[0] ? val[0] : ''
  179. this.queryParam.allocateCategory = val && val[1] ? val[1] : ''
  180. this.queryParam.allocateTypeSn = val && val[2] ? val[2] : ''
  181. },
  182. // 盘点库存日期
  183. handleStock () {
  184. this.$message.info('无盘点区间的起始/终止时间,请自行选择日期区间查询!')
  185. },
  186. // 创建时间 change
  187. dateChange (date) {
  188. if (date[0] && date[1]) {
  189. this.queryParam.time = date
  190. } else {
  191. this.queryParam.time = []
  192. }
  193. this.queryParam.beginDate = date[0] || ''
  194. this.queryParam.endDate = date[1] || ''
  195. },
  196. // 合计
  197. getCount (params) {
  198. allocateReportCount(params).then(res => {
  199. if (res.status == 200) {
  200. this.totalData = res.data
  201. } else {
  202. this.totalData = null
  203. }
  204. })
  205. },
  206. // 查询
  207. handleSearch () {
  208. const _this = this
  209. this.$refs.ruleForm.validate(valid => {
  210. if (valid) {
  211. _this.$refs.table.refresh(true)
  212. } else {
  213. _this.$message.error('请选择调拨开单日期')
  214. return false
  215. }
  216. })
  217. },
  218. // 重置
  219. resetSearchForm () {
  220. this.queryParam.time = [
  221. getDate.getCurrMonthDays().starttime,
  222. getDate.getCurrMonthDays().endtime
  223. ]
  224. this.$refs.rangeDate.resetDate(this.queryParam.time)
  225. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  226. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  227. this.queryParam.allocateNo = ''
  228. this.queryParam.creatorId = undefined
  229. this.queryParam.costTypeSn = undefined
  230. this.queryParam.allocateCategory = undefined
  231. this.queryParam.allocateTypeSn = undefined
  232. this.allocateTypeVal = []
  233. this.$refs.ruleForm.resetFields()
  234. this.totalData = null
  235. this.$refs.table.clearTable()
  236. },
  237. // 调拨类型
  238. getAllocateTypeAllList () {
  239. allocateTypeAllList().then(res => {
  240. if (res.status == 200) {
  241. this.allocateTypeList = res.data
  242. } else {
  243. this.allocateTypeList = []
  244. }
  245. })
  246. },
  247. // 操作员
  248. getUserList () {
  249. userQueryList({}).then(res => {
  250. if (res.status == 200) {
  251. this.operatorList = res.data
  252. } else {
  253. this.operatorList = []
  254. }
  255. })
  256. },
  257. filterOption (input, option) {
  258. return (
  259. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  260. )
  261. },
  262. pageInit () {
  263. const _this = this
  264. _this.getAllocateTypeAllList()
  265. _this.getUserList()
  266. this.$nextTick(() => {
  267. _this.setTableH()
  268. })
  269. },
  270. setTableH () {
  271. const tableSearchH = this.$refs.tableSearch.offsetHeight
  272. this.tableHeight = window.innerHeight - tableSearchH - 215
  273. }
  274. },
  275. mounted () {
  276. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  277. this.pageInit()
  278. this.resetSearchForm()
  279. }
  280. },
  281. activated () {
  282. // 如果是新页签打开,则重置当前页面
  283. if (this.$store.state.app.isNewTab) {
  284. this.pageInit()
  285. this.resetSearchForm()
  286. }
  287. },
  288. beforeRouteEnter (to, from, next) {
  289. next(vm => {})
  290. }
  291. }
  292. </script>