index.vue 56 KB

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