08a53babda9daf240711ef5164f95e4b7e5ab622.svn-base 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeName" @tab-click="handleTabClick">
  4. <el-tab-pane label="库存统计" name="first">
  5. <div class="search">
  6. <el-date-picker v-model="tab.table.getdataListParm.parammaps.inputDatetime" :clearable="false" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="float: left;width: 250px;margin-bottom:10px;" :picker-options="pickerOptions" />
  7. <el-input v-model="tab.table.getdataListParm.parammaps.feedname" class="filter-item" style="float: left;width: 245px;margin-bottom:10px;" placeholder="饲料名称" />
  8. <el-button class="successBorder" style="float: left;margin-left: 10px;margin-bottom:10px;" @click="handleSearch('first')">查询</el-button>
  9. <el-button class="export" style="float: right;margin-right: 10px;margin-bottom:10px;" icon="el-icon-upload2" @click="handleExport('tab1')">导出</el-button>
  10. </div>
  11. <div class="table">
  12. <el-table
  13. :key="tab.table.tableKey"
  14. v-loading="tab.table.listLoading"
  15. element-loading-text="给我一点时间"
  16. :data="tab.table.list"
  17. border
  18. fit
  19. highlight-current-row
  20. style="width: 100%;"
  21. :row-style="rowStyle"
  22. :cell-style="cellStyle"
  23. class="elTable table-fixed"
  24. >
  25. <el-table-column label="饲料名称" min-width="130px" align="center">
  26. <template slot-scope="scope">
  27. <span>{{ scope.row.feedname }}</span>
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="期初" min-width="130px" align="center">
  31. <el-table-column prop="startsum" align="center" label="期初库存(kg)" min-width="120" />
  32. <el-table-column prop="startprice" align="center" label="期初金额(元)" min-width="120" />
  33. </el-table-column>
  34. <el-table-column label="用量" min-width="110px" align="center">
  35. <el-table-column prop="laidsum" align="center" label="入库重量(kg)" min-width="120" />
  36. <el-table-column prop="usesumXT" align="center" label="系统出库重量(kg)" min-width="120" />
  37. <el-table-column prop="usesumRG" align="center" label="人工用料重量(kg)" min-width="120" />
  38. <el-table-column prop="usesumXH" align="center" label="损耗重量(kg)" min-width="120" />
  39. </el-table-column>
  40. <el-table-column label="期末" min-width="130px" align="center">
  41. <el-table-column prop="stopsum" align="center" label="期末库存(kg)" min-width="120" />
  42. <el-table-column prop="stopprice" align="center" label="期末金额(元)" min-width="120" />
  43. </el-table-column>
  44. </el-table>
  45. <pagination v-show="tab.table.total>=0" :total="tab.table.total" :page.sync="tab.table.getdataListParm.offset" :limit.sync="tab.table.getdataListParm.pagecount" @pagination="getTabList" />
  46. </div>
  47. </el-tab-pane>
  48. <el-tab-pane label="用料分析" name="second">
  49. <div class="search">
  50. <el-date-picker v-model="tab2.table.getdataListParm.parammaps.inputDatetime" :clearable="false" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 245px;" :picker-options="pickerOptions" />
  51. <span style="margin-left: 10px;">统计类型:</span>
  52. <el-radio v-model="tab2.radio" label="1" @change="changeRadio2">牲畜类别</el-radio>
  53. <el-radio v-model="tab2.radio" label="2" @change="changeRadio2">栏舍名称</el-radio>
  54. <el-radio v-model="tab2.radio" label="3" @change="changeRadio2">日期</el-radio>
  55. <el-radio v-model="tab2.radio" label="4" @change="changeRadio2">TMR设备编号</el-radio>
  56. <el-radio v-model="tab2.radio" label="5" @change="changeRadio2">班次</el-radio>
  57. <el-radio v-model="tab2.radio" label="6" @change="changeRadio2">车次</el-radio>
  58. <el-input v-if="tab2.isRadio1" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 200px;" placeholder="牲畜类别" />
  59. <el-input v-if="tab2.isRadio2" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 200px;" placeholder="栏舍名称" />
  60. <el-input v-if="tab2.isRadio3" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 200px;" placeholder="日期" />
  61. <el-input v-if="tab2.isRadio4" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 200px;" placeholder="TMR设备编号" />
  62. <el-input v-if="tab2.isRadio5" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 200px;" placeholder="班次" />
  63. <el-input v-if="tab2.isRadio6" v-model="tab2.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 200px;" placeholder="车次" />
  64. <el-button class="successBorder" @click="handleSearch('second')">查询</el-button>
  65. <el-button class="export" style="float: right;margin-right: 5px;" icon="el-icon-upload2" @click="handleExport('tab2')">导出</el-button>
  66. </div>
  67. <div v-if="tab2.table.list.length>0" class="table">
  68. <el-table
  69. v-if="tab2.table.list.length>0"
  70. :key="tab2.table.tableKey"
  71. v-loading="tab2.table.listLoading"
  72. element-loading-text="给我一点时间"
  73. :data="tab2.table.list"
  74. border
  75. fit
  76. highlight-current-row
  77. style="width: 100%;"
  78. :row-style="rowStyle"
  79. :cell-style="cellStyle"
  80. class="elTable table-fixed"
  81. >
  82. <el-table-column v-for="item in tab2.table.tableConfig" align="center" :label="item.label" :prop="item.prop">
  83. <el-table-column v-for="item1 in item.children" v-if="item.children || item.children.length>0" align="center" :label="item1.label" :prop="item1.prop">
  84. <el-table-column v-for="item2 in item1.children" v-if="item1.children || item1.children.length>0" :label="item2.label" :prop="item2.prop" />
  85. </el-table-column>
  86. </el-table-column>
  87. </el-table>
  88. </div>
  89. <div v-if="tab2.table.list.length==0" style="text-align: center;">暂无数据</div>
  90. </el-tab-pane>
  91. <el-tab-pane label="价格分析" name="third">
  92. <div class="search">
  93. <el-date-picker v-model="tab3.table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" :picker-options="pickerOptions" />
  94. <span style="margin-left: 10px;">统计类型:</span>
  95. <el-radio v-model="tab3.radio" label="1" @change="changeRadio3">牲畜类别</el-radio>
  96. <el-radio v-model="tab3.radio" label="2" @change="changeRadio3">栏舍名称</el-radio>
  97. <el-radio v-model="tab3.radio" label="3" @change="changeRadio3">日期</el-radio>
  98. <el-radio v-model="tab3.radio" label="4" @change="changeRadio3">TMR设备编号</el-radio>
  99. <el-input v-if="tab3.isRadio1" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="牲畜类别" />
  100. <el-input v-if="tab3.isRadio2" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="栏舍名称" />
  101. <el-input v-if="tab3.isRadio3" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="日期" />
  102. <el-input v-if="tab3.isRadio4" v-model="tab3.table.getdataListParm.parammaps.fname" class="filter-item" style="width: 245px;" placeholder="TMR设备编号" />
  103. <el-button class="successBorder" @click="handleSearch('third')">查询</el-button>
  104. <el-button class="export" style="float: right;margin-right: 5px;" icon="el-icon-upload2" @click="handleExport('tab3')">导出</el-button>
  105. </div>
  106. <div v-if="tab3.table.list.length>0" class="table">
  107. <el-table
  108. :key="tab3.table.tableKey"
  109. v-loading="tab3.table.listLoading"
  110. element-loading-text="给我一点时间"
  111. :data="tab3.table.list"
  112. border
  113. fit
  114. highlight-current-row
  115. style="width: 100%;"
  116. :row-style="rowStyle"
  117. :cell-style="cellStyle"
  118. class="elTable table-fixed"
  119. >
  120. <el-table-column v-for="item in tab3.table.tableConfig" align="center" :label="item.label" :prop="item.prop">
  121. <el-table-column v-for="item1 in item.children" v-if="item.children || item.children.length>0" align="center" :label="item1.label" :prop="item1.prop">
  122. <el-table-column v-for="item2 in item1.children" v-if="item1.children || item1.children.length>0" :label="item2.label" :prop="item2.prop" />
  123. </el-table-column>
  124. </el-table-column>
  125. </el-table>
  126. </div>
  127. <div v-if="tab2.table.list.length==0" style="text-align: center;">暂无数据</div>
  128. </el-tab-pane>
  129. </el-tabs>
  130. </div>
  131. </div>
  132. </template>
  133. <script>
  134. import { GetDataByName, GetReportform } from '@/api/common'
  135. import Cookies from 'js-cookie'
  136. import { parseTime } from '@/utils/index.js'
  137. import Pagination from '@/components/Pagination'
  138. import { json2excel, export_json_to_excel } from '@/utils/index.js'
  139. export default {
  140. name: 'PastureInventoryManagement',
  141. components: { Pagination },
  142. data() {
  143. return {
  144. pickerMinDate: '',
  145. pickerOptions: {
  146. onPick: ({ maxDate, minDate }) => {
  147. this.pickerMinDate = minDate.getTime()
  148. if (maxDate) {
  149. this.pickerMinDate = ''
  150. }
  151. },
  152. // 限制不能选择今天之后的日期
  153. disabledDate: (time) => {
  154. if (this.pickerMinDate !== '') {
  155. const one = 31 * 24 * 3600 * 1000
  156. const minTime = this.pickerMinDate - one
  157. let maxTime = this.pickerMinDate + one
  158. if (maxTime > new Date()) {
  159. maxTime = new Date()
  160. }
  161. return time.getTime() < minTime || time.getTime() > maxTime
  162. }
  163. return time.getTime() > Date.now()
  164. }
  165. },
  166. fileComment: [{ 'label': '商务文件评分', 'children': [{ 'label': '1' }, { 'label': '2' }, { 'label': '管理员' }] }],
  167. activeName: 'first',
  168. tab: {
  169. chartDate: [],
  170. table: {
  171. getdataListParm: {
  172. name: 'getfsStaticlist',
  173. page: 1,
  174. offset: 1,
  175. pagecount: 10,
  176. returntype: 'Map',
  177. parammaps: {
  178. pastureid: Cookies.get('pastureid'),
  179. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  180. stopTime: parseTime(new Date(), '{y}-{m}-{d}'),
  181. inputDatetime: [new Date(), new Date()],
  182. feedname: ''
  183. }
  184. },
  185. tableKey: 1,
  186. list: [],
  187. total: 0,
  188. listLoading: true
  189. }
  190. },
  191. tab2: {
  192. chartDate: [],
  193. table: {
  194. getdataListParm: {
  195. name: 'getMaterialAnalysisSC',
  196. page: 1,
  197. offset: 1,
  198. pagecount: '',
  199. returntype: 'Map',
  200. parammaps: {
  201. pastureid: Cookies.get('pastureid'),
  202. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  203. stopTime: parseTime(new Date(), '{y}-{m}-{d}'),
  204. inputDatetime: [new Date(), new Date()],
  205. fname: ''
  206. }
  207. },
  208. tableKey: 1,
  209. list: [],
  210. tableConfig: [],
  211. data: [],
  212. total: 0,
  213. listLoading: true
  214. },
  215. radio: '1',
  216. isRadio1: true,
  217. isRadio2: false,
  218. isRadio3: false,
  219. isRadio4: false,
  220. isRadio5: false,
  221. isRadio6: false
  222. },
  223. tab3: {
  224. chartDate: [],
  225. table: {
  226. getdataListParm: {
  227. name: 'getPriceAnalysisSC',
  228. page: 1,
  229. offset: 1,
  230. pagecount: 10,
  231. returntype: 'Map',
  232. parammaps: {
  233. pastureid: Cookies.get('pastureid'),
  234. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  235. stopTime: parseTime(new Date(), '{y}-{m}-{d}'),
  236. inputDatetime: [new Date(), new Date()],
  237. fname: ''
  238. }
  239. },
  240. tableKey: 1,
  241. list: [],
  242. tableConfig: [],
  243. total: 0,
  244. listLoading: true
  245. },
  246. radio: '1',
  247. isRadio1: true,
  248. isRadio2: false,
  249. isRadio3: false,
  250. isRadio4: false
  251. },
  252. downLoad: {},
  253. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  254. cellStyle: { padding: 0 + 'px' }
  255. }
  256. },
  257. created() {
  258. this.getTabList()
  259. this.getTimeFn()
  260. },
  261. methods: {
  262. getTimeFn() {
  263. const that = this
  264. const end = new Date()
  265. const start = new Date()
  266. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
  267. that.tab.chartDate[0] = parseTime(start, '{y}-{m}-{d}')
  268. that.tab.chartDate[1] = parseTime(end, '{y}-{m}-{d}')
  269. that.tab.table.getdataListParm.parammaps.inputDatetime[0] = parseTime(start, '{y}-{m}-{d}')
  270. that.tab.table.getdataListParm.parammaps.inputDatetime[1] = parseTime(end, '{y}-{m}-{d}')
  271. that.tab.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  272. that.tab.table.getdataListParm.parammaps.stopTime = parseTime(end, '{y}-{m}-{d}')
  273. that.tab2.chartDate[0] = parseTime(start, '{y}-{m}-{d}')
  274. that.tab2.chartDate[1] = parseTime(end, '{y}-{m}-{d}')
  275. that.tab2.table.getdataListParm.parammaps.inputDatetime[0] = parseTime(start, '{y}-{m}-{d}')
  276. that.tab2.table.getdataListParm.parammaps.inputDatetime[1] = parseTime(end, '{y}-{m}-{d}')
  277. that.tab2.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  278. that.tab2.table.getdataListParm.parammaps.stopTime = parseTime(end, '{y}-{m}-{d}')
  279. that.tab3.chartDate[0] = parseTime(start, '{y}-{m}-{d}')
  280. that.tab3.chartDate[1] = parseTime(end, '{y}-{m}-{d}')
  281. that.tab3.table.getdataListParm.parammaps.inputDatetime[0] = parseTime(start, '{y}-{m}-{d}')
  282. that.tab3.table.getdataListParm.parammaps.inputDatetime[1] = parseTime(end, '{y}-{m}-{d}')
  283. that.tab3.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  284. that.tab3.table.getdataListParm.parammaps.stopTime = parseTime(end, '{y}-{m}-{d}')
  285. },
  286. handleTabClick() {
  287. if (this.activeName == 'first') {
  288. this.getTabList()
  289. } else if (this.activeName == 'second') {
  290. this.getTab2List()
  291. } else if (this.activeName == 'third') {
  292. this.getTab3List()
  293. }
  294. },
  295. getTabList() {
  296. this.tab.table.listLoading = true
  297. GetDataByName(this.tab.table.getdataListParm).then(response => {
  298. console.log('库存统计table数据', response.data.list)
  299. if (response.data.list !== null) {
  300. this.tab.table.list = response.data.list
  301. this.tab.table.total = response.data.total
  302. } else {
  303. this.tab.table.list = []
  304. }
  305. setTimeout(() => {
  306. this.tab.table.listLoading = false
  307. }, 100)
  308. })
  309. },
  310. handleSearch(item) {
  311. if (item == 'first') {
  312. if (this.tab.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab.table.getdataListParm.parammaps.inputDatetime !== null) {
  313. this.tab.table.getdataListParm.parammaps.startTime = parseTime(this.tab.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  314. this.tab.table.getdataListParm.parammaps.stopTime = parseTime(this.tab.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  315. } else {
  316. this.tab.table.getdataListParm.parammaps.inputDatetime = ''
  317. this.tab.table.getdataListParm.parammaps.startTime = ''
  318. this.tab.table.getdataListParm.parammaps.stopTime = ''
  319. }
  320. this.getTabList()
  321. } else if (item == 'second') {
  322. if (this.tab2.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab2.table.getdataListParm.parammaps.inputDatetime !== null) {
  323. this.tab2.table.getdataListParm.parammaps.startTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  324. this.tab2.table.getdataListParm.parammaps.stopTime = parseTime(this.tab2.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  325. } else {
  326. this.tab2.table.getdataListParm.parammaps.inputDatetime = ''
  327. this.tab2.table.getdataListParm.parammaps.startTime = ''
  328. this.tab2.table.getdataListParm.parammaps.stopTime = ''
  329. }
  330. this.getTab2List()
  331. } else if (item == 'third') {
  332. if (this.tab3.table.getdataListParm.parammaps.inputDatetime !== '' && this.tab3.table.getdataListParm.parammaps.inputDatetime !== null) {
  333. this.tab3.table.getdataListParm.parammaps.startTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  334. this.tab3.table.getdataListParm.parammaps.stopTime = parseTime(this.tab3.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  335. } else {
  336. this.tab3.table.getdataListParm.parammaps.inputDatetime = ''
  337. this.tab3.table.getdataListParm.parammaps.startTime = ''
  338. this.tab3.table.getdataListParm.parammaps.stopTime = ''
  339. }
  340. this.getTab3List()
  341. }
  342. },
  343. // 用料分析
  344. getTab2List() {
  345. this.tab2.table.listLoading = true
  346. GetReportform(this.tab2.table.getdataListParm).then(response => {
  347. console.log('库存统计-用料分析', response.data.list)
  348. if (response.data.data !== null && response.data.data1 !== null) {
  349. this.tab2.table.data = response.data.data
  350. this.tab2.table.list = response.data.list.data1
  351. this.tab2.table.tableConfig = response.data.list.data2
  352. this.tab2.table.total = response.data.total
  353. } else {
  354. this.tab2.table.list = []
  355. this.tab2.table.data = []
  356. }
  357. console.log(this.tab2.table.list.length)
  358. setTimeout(() => {
  359. this.tab2.table.listLoading = false
  360. }, 100)
  361. })
  362. },
  363. changeRadio2() {
  364. console.log(this.tab2.radio)
  365. if (this.tab2.radio == '1') {
  366. this.tab2.isRadio1 = true,
  367. this.tab2.isRadio2 = false,
  368. this.tab2.isRadio3 = false,
  369. this.tab2.isRadio4 = false,
  370. this.tab2.isRadio5 = false,
  371. this.tab2.isRadio6 = false,
  372. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisSC'
  373. this.tab2.table.getdataListParm.offset = 1
  374. this.getTab2List()
  375. } else if (this.tab2.radio == '2') {
  376. this.tab2.isRadio1 = false,
  377. this.tab2.isRadio2 = true,
  378. this.tab2.isRadio3 = false,
  379. this.tab2.isRadio4 = false,
  380. this.tab2.isRadio5 = false,
  381. this.tab2.isRadio6 = false,
  382. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisLS'
  383. this.tab2.table.getdataListParm.offset = 1
  384. this.getTab2List()
  385. } else if (this.tab2.radio == '3') {
  386. this.tab2.isRadio1 = false,
  387. this.tab2.isRadio2 = false,
  388. this.tab2.isRadio3 = true,
  389. this.tab2.isRadio4 = false,
  390. this.tab2.isRadio5 = false,
  391. this.tab2.isRadio6 = false,
  392. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisRQ'
  393. this.tab2.table.getdataListParm.offset = 1
  394. this.getTab2List()
  395. } else if (this.tab2.radio == '4') {
  396. this.tab2.isRadio1 = false,
  397. this.tab2.isRadio2 = false,
  398. this.tab2.isRadio3 = false,
  399. this.tab2.isRadio4 = true,
  400. this.tab2.isRadio5 = false,
  401. this.tab2.isRadio6 = false,
  402. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisTMR'
  403. this.tab2.table.getdataListParm.offset = 1
  404. this.getTab2List()
  405. } else if (this.tab2.radio == '5') {
  406. this.tab2.isRadio1 = false,
  407. this.tab2.isRadio2 = false,
  408. this.tab2.isRadio3 = false,
  409. this.tab2.isRadio4 = false,
  410. this.tab2.isRadio5 = true,
  411. this.tab2.isRadio6 = false,
  412. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisBC'
  413. this.tab2.table.getdataListParm.offset = 1
  414. this.getTab2List()
  415. } else if (this.tab2.radio == '6') {
  416. this.tab2.isRadio1 = false,
  417. this.tab2.isRadio2 = false,
  418. this.tab2.isRadio3 = false,
  419. this.tab2.isRadio4 = false,
  420. this.tab2.isRadio5 = false,
  421. this.tab2.isRadio6 = true,
  422. this.tab2.table.getdataListParm.name = 'getMaterialAnalysisCC'
  423. this.tab2.table.getdataListParm.offset = 1
  424. this.getTab2List()
  425. }
  426. },
  427. // 价格分析
  428. getTab3List() {
  429. this.tab3.table.listLoading = true
  430. GetReportform(this.tab3.table.getdataListParm).then(response => {
  431. console.log('库存统计-价格分析', response.data.list)
  432. if (response.data.list.data1 !== null && response.data.list.data2 !== null) {
  433. this.tab3.table.list = response.data.list.data1
  434. this.tab3.table.tableConfig = response.data.list.data2
  435. this.tab3.table.total = response.data.total
  436. } else {
  437. this.tab3.table.list = []
  438. }
  439. setTimeout(() => {
  440. this.tab3.table.listLoading = false
  441. }, 100)
  442. })
  443. },
  444. changeRadio3() {
  445. console.log(this.tab3.radio)
  446. if (this.tab3.radio == '1') {
  447. this.tab3.isRadio1 = true,
  448. this.tab3.isRadio2 = false,
  449. this.tab3.isRadio3 = false,
  450. this.tab3.isRadio4 = false,
  451. this.tab3.table.getdataListParm.name = 'getPriceAnalysisSC'
  452. this.tab3.table.getdataListParm.offset = 1
  453. this.getTab3List()
  454. } else if (this.tab3.radio == '2') {
  455. this.tab3.isRadio1 = false,
  456. this.tab3.isRadio2 = true,
  457. this.tab3.isRadio3 = false,
  458. this.tab3.isRadio4 = false,
  459. this.tab3.table.getdataListParm.name = 'getPriceAnalysisLS'
  460. this.tab3.table.getdataListParm.offset = 1
  461. this.getTab3List()
  462. } else if (this.tab3.radio == '3') {
  463. this.tab3.isRadio1 = false,
  464. this.tab3.isRadio2 = false,
  465. this.tab3.isRadio3 = true,
  466. this.tab3.isRadio4 = false,
  467. this.tab3.table.getdataListParm.name = 'getPriceAnalysisRQ'
  468. this.tab3.table.getdataListParm.offset = 1
  469. this.getTab3List()
  470. } else if (this.tab3.radio == '4') {
  471. this.tab3.isRadio1 = false,
  472. this.tab3.isRadio2 = false,
  473. this.tab3.isRadio3 = false,
  474. this.tab3.isRadio4 = true,
  475. this.tab3.table.getdataListParm.name = 'getPriceAnalysisTMR'
  476. this.tab3.table.getdataListParm.offset = 1
  477. this.getTab3List()
  478. }
  479. },
  480. handleExport(item) {
  481. if (item == 'tab1') {
  482. console.log('库存统计导出')
  483. this.downLoad.getdataListParm = {}
  484. this.downLoad.getdataListParm.name = 'getfsStaticlist'
  485. this.downLoad.getdataListParm.pagecount = ''
  486. this.downLoad.getdataListParm.parammaps = this.tab.table.getdataListParm.parammaps
  487. GetDataByName(this.downLoad.getdataListParm).then(response => {
  488. if (response.data.list !== null) {
  489. this.$nextTick(() => {
  490. this.downLoad.list = response.data.list
  491. })
  492. } else {
  493. this.downLoad.list = []
  494. }
  495. import('@/vendor/Export5Excel').then(excel => {
  496. const multiHeader = [['饲料名称', '期初', '', '用量', '', '', '', '期末', '']]
  497. const multiHeader2 = [['', '期初库存(kg)', '期初金额(元)', '入库重量(kg)', '系统出库重量(kg)', '人工用料重量(kg)', '损耗重量', '期末库存(kg)', '期末金额(元)']]
  498. const filterVal = ['feedname', 'startsum', 'startprice', 'laidsum', 'usesumXT', 'usesumRG', 'usesumXH', 'stopsum', 'stopprice']
  499. const data = this.downLoad.list.map((v) => filterVal.map((j) => v[j]))
  500. const merges = ['A1:A2', 'B1:C1', 'D1:G1', 'H1:I1']
  501. excel.export_json_to_excel({ multiHeader, multiHeader2, data, filename: '库存统计', merges })
  502. })
  503. })
  504. } else if (item == 'tab2') {
  505. console.log('用料分析导出数据', this.tab2.table.list)
  506. console.log('用料分析导出表头', this.tab2.table.tableConfig)
  507. var exportData = []
  508. var exportTitle1 = [] // 一级标题
  509. var exportTitle2 = [] // 二级标题
  510. for (let i = 0; i < this.tab2.table.tableConfig.length; i++) {
  511. exportTitle1.push(this.tab2.table.tableConfig[i].label)
  512. for (let j = 0; j < this.tab2.table.tableConfig[i].children.length; j++) {
  513. exportTitle2.push(this.tab2.table.tableConfig[i].children[j].label)
  514. }
  515. }
  516. console.log('一级标题exportTitle1', exportTitle1)
  517. console.log('二级标题exportTitle2', exportTitle2)
  518. var headerArr = []// 处理一级标题
  519. for (let i = 0; i < exportTitle1.length; i++) {
  520. if (i > 0) {
  521. headerArr.push(exportTitle1[i], '', '', '')
  522. } else {
  523. headerArr.push(exportTitle1[i])
  524. }
  525. }
  526. console.log('一级表头处理后', headerArr)
  527. var valueArr = [] // 对应字段
  528. for (let i = 0; i < exportTitle2.length; i++) {
  529. if (i == 0) {
  530. valueArr.push('A')
  531. } else {
  532. valueArr.push('a' + [i - 1])
  533. }
  534. }
  535. console.log('对应字段valueArr', valueArr)
  536. if (headerArr.length > 0) {
  537. import('@/vendor/Export3Excel').then((excel) => {
  538. const multiHeader = [
  539. headerArr
  540. ]
  541. const multiHeader2 = []
  542. const tHeader = exportTitle2
  543. const filterVal = valueArr// 表头所对应的字段,这里未填写
  544. const data = this.tab2.table.list.map(v => filterVal.map(j => v[j]))
  545. // const data = [];
  546. // 进行所有表头的单元格合并
  547. // const merges = ['A1:A1', 'B1:E1','F1:J1' ];
  548. const merges = ['A1:A1']
  549. excel.export_json_to_excel({ multiHeader, multiHeader2, header: tHeader, data, filename: '用料分析', merges })
  550. })
  551. }
  552. } else if (item == 'tab3') {
  553. console.log('价格分析导出')
  554. console.log('价格分析导出数据', this.tab3.table.list)
  555. console.log('价格分析导出表头', this.tab3.table.tableConfig)
  556. var exportData = []
  557. var exportTitle1 = [] // 一级标题
  558. var exportTitle2 = [] // 二级标题
  559. for (let i = 0; i < this.tab3.table.tableConfig.length; i++) {
  560. exportTitle1.push(this.tab3.table.tableConfig[i].label)
  561. for (let j = 0; j < this.tab3.table.tableConfig[i].children.length; j++) {
  562. exportTitle2.push(this.tab3.table.tableConfig[i].children[j].label)
  563. }
  564. }
  565. console.log('一级标题exportTitle1', exportTitle1)
  566. console.log('二级标题exportTitle2', exportTitle2)
  567. var headerArr = []// 处理一级标题
  568. for (let i = 0; i < exportTitle1.length; i++) {
  569. if (i > 0) {
  570. headerArr.push(exportTitle1[i], '')
  571. } else {
  572. headerArr.push(exportTitle1[i])
  573. }
  574. }
  575. console.log('一级表头处理后', headerArr)
  576. var valueArr = [] // 对应字段
  577. for (let i = 0; i < exportTitle2.length; i++) {
  578. if (i == 0) {
  579. valueArr.push('A')
  580. } else {
  581. valueArr.push('a' + [i - 1])
  582. }
  583. }
  584. console.log('对应字段valueArr', valueArr)
  585. if (headerArr.length > 0) {
  586. import('@/vendor/Export3Excel').then((excel) => {
  587. const multiHeader = [
  588. headerArr
  589. ]
  590. const multiHeader2 = []
  591. const tHeader = exportTitle2
  592. const filterVal = valueArr// 表头所对应的字段,这里未填写
  593. const data = this.tab3.table.list.map(v => filterVal.map(j => v[j]))
  594. // const data = [];
  595. // 进行所有表头的单元格合并
  596. // const merges = ['A1:A1', 'B1:E1','F1:J1' ];
  597. const merges = ['A1:A1']
  598. excel.export_json_to_excel({ multiHeader, multiHeader2, header: tHeader, data, filename: '价格分析', merges })
  599. })
  600. }
  601. }
  602. },
  603. format(jsonData) { // 数据处理
  604. const dataList = []
  605. for (let i = 0; i < jsonData.length; i++) {
  606. const list = []
  607. list.push(jsonData[i].index)
  608. list.push(jsonData[i].Personel)
  609. list.push(jsonData[i].address)
  610. for (let j = 0; j < jsonData[0]['time'].length; j++) {
  611. list.push(jsonData[i]['time'][j].morning)
  612. list.push(jsonData[i]['time'][j].afternoon)
  613. }
  614. dataList.push(list)
  615. }
  616. return dataList
  617. }
  618. }
  619. }
  620. </script>
  621. <style lang="scss" scoped>
  622. .search{margin-bottom:10px;}
  623. </style>