index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div class="app-container">
  3. <div v-if="isPercentage" class="percentage" style="width: 210px;height: 90px;background: #fff;position: fixed;bottom: 0;left: 0;z-index: 9999999999999;">
  4. <h4 style="padding-left: 10px;line-height: 0;">导出进度:</h4>
  5. <el-progress style="padding-left: 10px;" :text-inside="true" :stroke-width="26" :percentage="percentage" />
  6. </div>
  7. <div class="filter-container">
  8. <el-select v-model="getdataListParm.parammaps.type" class="filter-item" style="width: 120px;" @change="changeType">
  9. <el-option v-for="item in types" :key="item.id" :label="item.name" :value="item.id" />
  10. </el-select>
  11. <el-date-picker v-model="getdataListParm.parammaps.buyerDate" type="month" style="width: 250px;top:-3px;" placeholder="选择月份" format="yyyy-MM" value-format="yyyy-MM" />
  12. <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
  13. <el-button class="filter-item" type="success" icon="el-icon-upload2" @click="handleDownload">导出</el-button>
  14. </div>
  15. <el-table
  16. :key="tableKey"
  17. v-loading="listLoading"
  18. element-loading-text="给我一点时间"
  19. :data="list"
  20. border
  21. fit
  22. highlight-current-row
  23. style="width: 100%;"
  24. :row-style="rowStyle"
  25. :cell-style="cellStyle"
  26. class="elTable"
  27. :max-height="myHeight"
  28. @sort-change="tableSort1"
  29. >
  30. <el-table-column label="序号" align="center" type="index" width="50px">
  31. <template slot-scope="scope">
  32. <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column v-if="isPasture" label="牧场" min-width="140px" align="center">
  36. <template slot-scope="scope">
  37. <span>{{ scope.row.pastureName }}</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column v-if="isProvider" label="供应商" min-width="140px" align="center">
  41. <template slot-scope="scope">
  42. <span>{{ scope.row.providerName }}</span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="订单数" min-width="140px" align="center" sortable prop="orderCount" />
  46. <el-table-column label="按时单数" min-width="140px" align="center" sortable prop="ontimeCount" />
  47. <el-table-column label="未到单数" min-width="140px" align="center" sortable prop="noCount" />
  48. <el-table-column label="到货及时率" min-width="140px" align="center" sortable prop="orderCount2">
  49. <template slot-scope="scope">
  50. <span>{{ scope.row.orderCount2 }}%</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="物料种数" min-width="140px" align="center" sortable prop="classCount" />
  54. <el-table-column label="单项完成量" min-width="140px" align="center" sortable prop="ontimeClassCount" />
  55. <el-table-column label="单项完成率" min-width="140px" align="center" sortable prop="ontimeClassCount2">
  56. <template slot-scope="scope">
  57. <span>{{ scope.row.ontimeClassCount2 }}%</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="订单量" min-width="140px" align="center" sortable prop="orderSum" />
  61. <el-table-column label="到货量" min-width="140px" align="center" sortable prop="receiveSum" />
  62. <el-table-column label="到货完成率" min-width="140px" align="center" sortable prop="receiveSum2">
  63. <template slot-scope="scope">
  64. <span>{{ scope.row.receiveSum2 }}%</span>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <pagination
  69. v-if="isPasture"
  70. v-show="total>0"
  71. :total="total"
  72. :page.sync="getdataListParm.offset"
  73. :limit.sync="getdataListParm.pagecount"
  74. @pagination="get_table_data"
  75. />
  76. <pagination
  77. v-if="isProvider"
  78. v-show="total>0"
  79. :total="totalProvider"
  80. :page.sync="getProviderParm.offset"
  81. :limit.sync="getProviderParm.pagecount"
  82. @pagination="getProviderList"
  83. />
  84. </div>
  85. </template>
  86. <script>
  87. import waves from '@/directive/waves' // waves directive
  88. import { GetDataByNames, GetDataByName, GetAccount } from '@/api/common'
  89. import Pagination from '@/components/Pagination'
  90. import Cookies from 'js-cookie'
  91. import { parseTime, json2excel, sortChange } from '@/utils/index.js'
  92. export default {
  93. name: 'TimelyArrivalRate',
  94. components: { Pagination },
  95. directives: { waves },
  96. filters: {
  97. keepTwoNum(value) {
  98. value = Number(value)
  99. return value.toFixed(2)
  100. }
  101. },
  102. data() {
  103. return {
  104. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  105. cellStyle: { padding: 0 + 'px' },
  106. types: [{ id: 0, name: '按牧场' }, { id: 1, name: '按供应商' }],
  107. findAllPasture: [],
  108. requestParams: [{ name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }}, { name: 'getPastureRoleList', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid'), empId: this.$store.state.user.employeid }}],
  109. tableKey: 0,
  110. list: [],
  111. total: 0,
  112. listLoading: true,
  113. isPasture: true,
  114. getdataListParm: {
  115. name: 'getOnTineRateListbyPasture',
  116. page: 1,
  117. offset: 1,
  118. pagecount: 10,
  119. returntype: 'Map',
  120. parammaps: {
  121. buyerDate: parseTime(new Date(), '{y}-{m}'),
  122. type: 0
  123. }
  124. },
  125. isProvider: false,
  126. totalProvider: 0,
  127. getProviderParm: {
  128. name: 'getOnTineRateListbyProvider',
  129. page: 1,
  130. offset: 1,
  131. pagecount: 10,
  132. returntype: 'Map',
  133. parammaps: {
  134. buyerDate: parseTime(new Date(), '{y}-{m}')
  135. }
  136. },
  137. Type: 0,
  138. downLoadParm: {},
  139. downLoadList: [],
  140. isPercentage: false,
  141. percentage: 1,
  142. myHeight: document.documentElement.clientHeight - 85 - 150
  143. }
  144. },
  145. created() {
  146. this.get_select_list()
  147. this.get_table_data()
  148. },
  149. mounted() {
  150. },
  151. methods: {
  152. tableSort1(column) {
  153. sortChange(column, this.list)
  154. },
  155. get_select_list() {
  156. GetDataByNames(this.requestParams).then(response => {
  157. this.findAllPasture = response.data.getPastureRoleList.list // response.data.findAllPasture.list
  158. })
  159. },
  160. get_table_data() {
  161. GetDataByName(this.getdataListParm).then(response => {
  162. console.log('table数据', response.data.list)
  163. for (let i = 0; i < response.data.list.length; i++) {
  164. if (response.data.list[i].ontimeCount !== 0 && response.data.list[i].orderCount !== 0) {
  165. this.$set(response.data.list[i], 'orderCount2', (parseFloat(response.data.list[i].ontimeCount) / parseFloat(response.data.list[i].orderCount) * 100).toFixed(2))
  166. } else {
  167. this.$set(response.data.list[i], 'orderCount2', 0)
  168. }
  169. if (response.data.list[i].ontimeClassCount !== 0 && response.data.list[i].classCount !== 0) {
  170. this.$set(response.data.list[i], 'ontimeClassCount2', (parseFloat(response.data.list[i].ontimeClassCount) / parseFloat(response.data.list[i].classCount) * 100).toFixed(2))
  171. } else {
  172. this.$set(response.data.list[i], 'ontimeClassCount2', 0)
  173. }
  174. if (response.data.list[i].receiveSum !== 0 && response.data.list[i].orderSum !== 0) {
  175. this.$set(response.data.list[i], 'receiveSum2', (parseFloat(response.data.list[i].receiveSum) / parseFloat(response.data.list[i].orderSum) * 100).toFixed(2))
  176. } else {
  177. this.$set(response.data.list[i], 'receiveSum2', 0)
  178. }
  179. }
  180. this.list = response.data.list
  181. this.pageNum = response.data.pageNum
  182. this.pageSize = response.data.pageSize
  183. this.total = response.data.total
  184. setTimeout(() => {
  185. this.listLoading = false
  186. }, 100)
  187. })
  188. },
  189. getProviderList() {
  190. GetDataByName(this.getProviderParm).then(response => {
  191. console.log('table数据', response.data.list)
  192. this.list = response.data.list
  193. this.pageNumEquipmentType = response.data.pageNum
  194. this.pageSizeEquipmentType = response.data.pageSize
  195. if (response.data.total) {
  196. this.totalProvider = response.data.total
  197. }
  198. console.log(response.data.total)
  199. console.log(this.totalProvider)
  200. setTimeout(() => {
  201. this.listLoading = false
  202. }, 100)
  203. })
  204. },
  205. form_search() {
  206. if (this.getdataListParm.parammaps.type === 0) {
  207. this.isPasture = true
  208. this.getdataListParm.offset = 1
  209. this.get_table_data()
  210. } else {
  211. this.isPasture = false
  212. this.getProviderParm.offset = 1
  213. this.getProviderParm.parammaps.buyerDate = this.getdataListParm.parammaps.buyerDate
  214. this.getProviderList()
  215. }
  216. },
  217. changeType(val) {
  218. this.Type = val
  219. if (this.Type == 0) {
  220. this.listLoading = true
  221. this.getdataListParm.parammaps.pastureName = this.pastureName
  222. this.isPasture = true
  223. this.isProvider = false
  224. this.get_table_data()
  225. } else {
  226. this.listLoading = true
  227. this.isPasture = false
  228. this.isProvider = true
  229. this.getProviderParm.parammaps.pastureName = this.pastureName
  230. this.getProviderList()
  231. }
  232. },
  233. handleDownload() {
  234. console.log('点击了导出')
  235. console.log(this.Type)
  236. this.$alert('备件到货及时率正在导出中,请勿刷新或离开本页面,若导出时间过长,建议缩小导出数据范围重新导出', {})
  237. this.isPercentage = true
  238. this.percentage = 1
  239. var timer = setInterval(() => {
  240. this.percentage += 5
  241. if (this.percentage > 95) {
  242. this.percentage = 99
  243. clearInterval(timer)
  244. }
  245. this.percentage = this.percentage
  246. }, 1000)
  247. if (this.Type == 0) {
  248. this.downLoadParm.name = 'getOnTineRateListbyPasture'
  249. this.downLoadParm.returntype = 'Map'
  250. this.downLoadParm.parammaps = this.getdataListParm.parammaps
  251. GetAccount(this.downLoadParm).then(response => {
  252. if (response.data.list !== '') {
  253. this.percentage = 99
  254. setTimeout(() => {
  255. this.isPercentage = false
  256. }, 2000)
  257. }
  258. this.$nextTick(() => {
  259. this.downLoadList = response.data.list
  260. if (response.data.list.length > 0) {
  261. for (var i = 0; i < response.data.list.length; i++) {
  262. this.downLoadList[i].DHJSL = ((parseFloat(response.data.list[i].ontimeCount) / parseFloat(response.data.list[i].orderCount)) * 100).toFixed(2) + '%'
  263. this.downLoadList[i].DXWCL = ((parseFloat(response.data.list[i].ontimeClassCount) / parseFloat(response.data.list[i].classCount)) * 100).toFixed(2) + '%'
  264. this.downLoadList[i].DHWCL = ((parseFloat(response.data.list[i].receiveSum) / parseFloat(response.data.list[i].orderSum)) * 100).toFixed(2) + '%'
  265. }
  266. }
  267. console.log(this.downLoadList)
  268. const ExcelDatas = [
  269. {
  270. tHeader: ['牧场', '订单数', '按时单数', '未到单数', '到货及时率', '物料种数', '单项完成量', '单项完成率', '订单量', '到货量', '到货完成率'],
  271. filterVal: ['pastureName', 'orderCount', 'ontimeCount', 'noCount', 'DHJSL', 'classCount', 'ontimeClassCount', 'DXWCL', 'orderSum', 'receiveSum', 'DHWCL'],
  272. tableDatas: this.downLoadList,
  273. sheetName: '备件到货及时率'
  274. }
  275. ]
  276. json2excel(ExcelDatas, '备件到货及时率', true, 'xlsx')
  277. })
  278. })
  279. } else if (this.Type == 1) {
  280. this.downLoadParm.name = 'getOnTineRateListbyProvider'
  281. this.downLoadParm.returntype = 'Map'
  282. this.downLoadParm.parammaps = this.getdataListParm.parammaps
  283. GetAccount(this.downLoadParm).then(response => {
  284. this.$nextTick(() => {
  285. this.downLoadList = response.data.list
  286. if (response.data.list.length > 0) {
  287. for (var i = 0; i < response.data.list.length; i++) {
  288. this.downLoadList[i].DHJSL = ((parseFloat(response.data.list[i].ontimeCount) / parseFloat(response.data.list[i].orderCount)) * 100).toFixed(2) + '%'
  289. this.downLoadList[i].DXWCL = ((parseFloat(response.data.list[i].ontimeClassCount) / parseFloat(response.data.list[i].classCount)) * 100).toFixed(2) + '%'
  290. this.downLoadList[i].DHWCL = ((parseFloat(response.data.list[i].receiveSum) / parseFloat(response.data.list[i].orderSum)) * 100).toFixed(2) + '%'
  291. }
  292. }
  293. console.log(this.downLoadList)
  294. const ExcelDatas = [
  295. {
  296. tHeader: ['供应商', '订单数', '按时单数', '未到单数', '到货及时率', '物料种数', '单项完成量', '单项完成率', '订单量', '到货量', '到货完成率'],
  297. filterVal: ['providerName', 'orderCount', 'ontimeCount', 'noCount', 'DHJSL', 'classCount', 'ontimeClassCount', 'DXWCL', 'orderSum', 'receiveSum', 'DHWCL'],
  298. tableDatas: this.downLoadList,
  299. sheetName: '备件到货及时率'
  300. }
  301. ]
  302. json2excel(ExcelDatas, '备件到货及时率', true, 'xlsx')
  303. })
  304. })
  305. }
  306. }
  307. }
  308. }
  309. </script>