404ba57c7ae521c35e8573e117073fae135e4be8.svn-base 29 KB

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