e50f315ac9466238f14f067ad874a247790c753b.svn-base 31 KB

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