e2e48027b836e6d1629445d76f4d81207a344a5b.svn-base 39 KB

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