3cc303cdbdc2aa3cc3e57a191878fe0e069e10ed.svn-base 43 KB

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