index.vue 63 KB

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