index.vue 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. <template>
  2. <div class="app-container">
  3. <div v-if="isPercentage" class="percentage" style="width: 210px;height: 90px;background: #fff;position: fixed;bottom: 0;left: 0;z-index: 9999999999999;">
  4. <h4 style="padding-left: 10px;line-height: 0;">导出进度:</h4>
  5. <el-progress style="padding-left: 10px;" :text-inside="true" :stroke-width="26" :percentage="percentage" />
  6. </div>
  7. <div class="filter-container">
  8. <el-select v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" style="width: 140px;" class="filter-item" @change="changePastureName">
  9. <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
  10. </el-select>
  11. <el-select v-model="getdataListParm.parammaps.departName" style="width: 140px;" clearable placeholder="部门" class="filter-item">
  12. <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.name" />
  13. </el-select>
  14. <el-input v-model="getdataListParm.parammaps.formNumber" placeholder="编号" style="width: 140px;" class="filter-item" />
  15. <el-input v-model="getdataListParm.parammaps.formName" placeholder="表名称" style="width: 140px;" class="filter-item" />
  16. <el-select v-model="getdataListParm.parammaps.formType" style="width: 140px;" clearable placeholder="表结构" class="filter-item">
  17. <el-option v-for="item in useTypes" :key="item.id" :label="item.name" :value="item.name" />
  18. </el-select>
  19. <el-date-picker v-model="getdataListParm.parammaps.createDate" type="date" placeholder="日期" style="width:140px;top:-3px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" />
  20. <el-date-picker v-model="getdataListParm.parammaps.inputDatetime" clearable class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;margin-right: 10px;" />
  21. <div>
  22. <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
  23. <el-button v-if="isElecAdd" class="filter-item" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
  24. <el-button v-waves class="filter-item" type="info" icon="el-icon-tickets" @click="handleDownloadTemp">模板</el-button>
  25. <el-button v-if="isElecExport" v-waves class="filter-item" type="success" icon="el-icon-download" @click="handleDownload">导出数据</el-button>
  26. <el-upload style="display: inline-block;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
  27. <el-button v-if="isElecImport" v-waves class="filter-item" type="warning" icon="el-icon-upload2" @click="form_search">导入</el-button>
  28. </el-upload>
  29. <el-button class="filter-item" type="danger" icon="el-icon-download" @click="form_delete">删除</el-button>
  30. <el-button class="filter-item" icon="el-icon-share" @click="formEchart">折线图</el-button>
  31. </div>
  32. </div>
  33. <el-table
  34. :key="tableKey"
  35. v-loading="listLoading"
  36. element-loading-text="给我一点时间"
  37. :data="list"
  38. border
  39. fit
  40. highlight-current-row
  41. style="width: 100%;"
  42. :row-style="rowStyle"
  43. :cell-style="cellStyle"
  44. class="elTable"
  45. @sort-change="tableSort1"
  46. :max-height="myHeight"
  47. >
  48. <el-table-column label="序号" align="center" type="index" width="50px">
  49. <template slot-scope="scope">
  50. <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="牧场" width="90px" align="center">
  54. <template slot-scope="scope">
  55. <span>{{ scope.row.pastureName }}</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="部门" width="80px" align="center">
  59. <template slot-scope="scope">
  60. <span>{{ scope.row.departName }}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="编号" width="90px" align="center">
  64. <template slot-scope="scope">
  65. <span>{{ scope.row.elecNumber }}</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="名称" width="80px" align="center">
  69. <template slot-scope="scope">
  70. <span>{{ scope.row.elecName }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column label="表结构" width="80px" align="center">
  74. <template slot-scope="scope">
  75. <span>{{ scope.row.useType }}</span>
  76. </template>
  77. </el-table-column>
  78. <!-- <el-table-column label="上次值" width="90px" align="center">
  79. <template slot-scope="scope">
  80. <span>{{ scope.row.lastAmount }}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="本次值" width="80px" align="center">
  84. <template slot-scope="scope">
  85. <span>{{ scope.row.endAmount }}</span>
  86. </template>
  87. </el-table-column> -->
  88. <el-table-column label="当天用电量(度)" sortable prop="elecConsumption" width="80px" align="center">
  89. <template slot-scope="scope">
  90. <span>{{ scope.row.elecConsumption }}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="单价" sortable prop="price" width="80px" align="center">
  94. <template slot-scope="scope">
  95. <span>{{ scope.row.price }}</span>
  96. </template>
  97. </el-table-column>
  98. <!-- <el-table-column label="倍率" sortable prop="Multiple" width="80px" align="center">
  99. <template slot-scope="scope">
  100. <span>{{ scope.row.Multiple }}</span>
  101. </template>
  102. </el-table-column> -->
  103. <el-table-column label="当天费用" sortable prop="sumPrice" width="80px" align="center">
  104. <template slot-scope="scope">
  105. <span>{{ scope.row.sumPrice }}</span>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="记录人" min-width="110px" align="center">
  109. <template slot-scope="scope">
  110. <span>{{ scope.row.putName }}</span>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="日期" min-width="110px" align="center" sortable prop="dateFormat" />
  114. <el-table-column label="备注" min-width="110px" align="center">
  115. <template slot-scope="scope">
  116. <span>{{ scope.row.note }}</span>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width" fixed="right">
  120. <template slot-scope="{row}">
  121. <el-button v-if="isElecModify" type="success" size="mini" @click="form_edit(row)">编辑</el-button>
  122. <el-button type="primary" size="mini" style="width:70px" @click="handleDosageRecord(row)">用量记录</el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <!-- 分页 -->
  127. <pagination v-show="total>0" :total="total" :page.sync="getdataListParm.offset" :limit.sync="getdataListParm.pagecount" @pagination="get_table_data" />
  128. <!-- 弹出层新增or修改 -->
  129. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
  130. <el-form ref="temp" :rules="rules" :model="temp" label-position="right" label-width="110px">
  131. <el-row>
  132. <el-col :span="8">
  133. <el-form-item label="电表编号:" prop="formNumber">
  134. <el-autocomplete ref="formNumber" v-model="temp.formNumber" value-key="formNumber" class="inline-input" :fetch-suggestions="formNumberSearch" placeholder="请输入内容" :disabled="dialogStatus==='update'" style="width:100%;" @select="handleformNumberSelect" @blur="blurSelect" />
  135. </el-form-item>
  136. </el-col>
  137. <el-col :span="8">
  138. <el-form-item label="电表名称:" prop="formName">
  139. <el-autocomplete ref="formName" v-model="temp.formName" value-key="formName" class="inline-input" :fetch-suggestions="formNameSearch" placeholder="请输入内容" :disabled="dialogStatus==='update'" style="width:100%;" @select="blurSelect" />
  140. </el-form-item>
  141. </el-col>
  142. <!-- <el-col :span="8">
  143. <el-form-item label="上次值(m³):" prop="aAmount">
  144. <el-input ref="aAmount" v-model="temp.aAmount" disabled />
  145. </el-form-item>
  146. </el-col> -->
  147. </el-row>
  148. <el-row>
  149. <el-col :span="6">
  150. <el-form-item label="类型:">
  151. <span>{{ temp.useType }}</span>
  152. </el-form-item>
  153. </el-col>
  154. <el-col :span="6">
  155. <el-form-item label="牧场:">
  156. <span>{{ temp.pastureName }}</span>
  157. </el-form-item>
  158. </el-col>
  159. <el-col :span="6">
  160. <el-form-item label="部门:">
  161. <span>{{ temp.departName }}</span>
  162. </el-form-item>
  163. </el-col>
  164. <el-col :span="6">
  165. <el-form-item label="责任人:">
  166. <span>{{ temp.employeName1 }}</span>
  167. </el-form-item>
  168. </el-col>
  169. </el-row>
  170. <el-row>
  171. <el-col :span="8">
  172. <el-form-item label="用量(度):" prop="consumption">
  173. <el-input ref="consumption" v-model="temp.consumption" @blur="handleBlurConsumption" />
  174. </el-form-item>
  175. </el-col>
  176. <!-- <el-col :span="8">
  177. <el-form-item label="当前值(m³):" prop="endAmount">
  178. <el-input ref="endAmount" v-model="temp.endAmount" @blur="handleBlurEndAmount" />
  179. </el-form-item>
  180. </el-col> -->
  181. <el-col :span="8">
  182. <el-form-item label="单价(元):" prop="price1">
  183. <el-input ref="price" v-model="temp.price1" :disabled="dialogStatus==='update'" />
  184. </el-form-item>
  185. </el-col>
  186. </el-row>
  187. <el-row>
  188. <el-col :span="8">
  189. <el-form-item label="备注:" prop="note">
  190. <el-input ref="note" v-model="temp.note" />
  191. </el-form-item>
  192. </el-col>
  193. <el-col :span="8">
  194. <el-form-item label="当前时间:" prop="date">
  195. <el-date-picker v-model="temp.date" type="date" placeholder="当前时间" format="yyyy-MM-dd" value-format="yyyy-MM-dd" disabled style="width:100%;" />
  196. </el-form-item>
  197. </el-col>
  198. </el-row>
  199. <el-row>
  200. <!-- <el-col :span="8">
  201. <el-form-item label="倍率:">
  202. <el-input ref="rate" v-model="temp.rate" disabled />
  203. </el-form-item>
  204. </el-col> -->
  205. <el-col :span="8">
  206. <el-form-item label="负责人:" prop="employeId">
  207. <el-select v-model="temp.employeId" placeholder="负责人" class="filter-item" style="width:100%;">
  208. <el-option v-for="item in findAllEmploye" :key="item.id" :label="item.name" :value="item.id" />
  209. </el-select>
  210. </el-form-item>
  211. </el-col>
  212. </el-row>
  213. </el-form>
  214. <div slot="footer" class="dialog-footer">
  215. <el-button v-if="dialogStatus==='create'" ref="createb" type="success" :disabled="isokDisable" @click="add_dialog_save_again()">保存并新增</el-button>
  216. <el-button type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
  217. <el-button @click="dialogFormVisible = false;get_table_data()">取消并关闭</el-button>
  218. </div>
  219. </el-dialog>
  220. <!-- 用量记录 -->
  221. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormDosageRecord" :close-on-click-modal="false">
  222. <div class="dosageRecord">
  223. <div style="position: absolute;top:20px;left:100px;font:18px/24px '' ;color:#303133;">
  224. <span style="margin:0 10px;">表名称:{{ dosageRecordTemp.formName }}</span>
  225. <span>表编号:{{ dosageRecordTemp.formNumber }}</span>
  226. </div>
  227. <el-table
  228. :key="tableKey"
  229. v-loading="listLoadingDosageRecord"
  230. element-loading-text="给我一点时间"
  231. :data="listDosageRecord"
  232. border
  233. fit
  234. highlight-current-row
  235. style="width: 100%;"
  236. :row-style="rowStyle"
  237. :cell-style="cellStyle"
  238. class="elTable"
  239. @sort-change="tableSort2"
  240. >
  241. <el-table-column label="序号" align="center" type="index" width="50px">
  242. <template slot-scope="scope">
  243. <span>{{ scope.$index + (pageNumDosageRecord-1) * pageSizeDosageRecord + 1 }}</span>
  244. </template>
  245. </el-table-column>
  246. <!-- <el-table-column label="上次值" min-width="110px" align="center">
  247. <template slot-scope="scope">
  248. <span>{{ scope.row.lastAmount }}</span>
  249. </template>
  250. </el-table-column>
  251. <el-table-column label="本次值" min-width="110px" align="center">
  252. <template slot-scope="scope">
  253. <span>{{ scope.row.endAmount }}</span>
  254. </template>
  255. </el-table-column> -->
  256. <el-table-column label="用量(度)" sortable prop="waterConsumption" min-width="110px" align="center">
  257. <template slot-scope="scope">
  258. <span>{{ scope.row.waterConsumption }}</span>
  259. </template>
  260. </el-table-column>
  261. <el-table-column label="单价" sortable prop="price" align="center" width="150">
  262. <template slot-scope="scope">
  263. <span>{{ scope.row.price }}</span>
  264. </template>
  265. </el-table-column>
  266. <el-table-column label="总价" sortable prop="sumPrice" align="center" width="150">
  267. <template slot-scope="scope">
  268. <span>{{ scope.row.sumPrice }}</span>
  269. </template>
  270. </el-table-column>
  271. <el-table-column label="记录人" width="150px" align="center">
  272. <template slot-scope="scope">
  273. <span>{{ scope.row.empname }}</span>
  274. </template>
  275. </el-table-column>
  276. <el-table-column label="记录日期" min-width="110px" align="center" sortable prop="date" />
  277. </el-table>
  278. <pagination v-show="totalDosageRecord>=0" :total="totalDosageRecord" :page.sync="getDosageRecordListParm.offset" :limit.sync="getDosageRecordListParm.pagecount" @pagination="getDosageRecordList" />
  279. <div slot="footer" class="dialog-footer">
  280. <el-button @click="dialogFormDosageRecord = false">关闭</el-button>
  281. </div>
  282. </div>
  283. </el-dialog>
  284. <!-- 删除 -->
  285. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormDelete" :close-on-click-modal="false" width="40%">
  286. <el-form ref="deleteTemp" :rules="rules" :model="deleteTemp" label-position="right" label-width="190px">
  287. <el-row>
  288. <el-col :span="8">
  289. <el-form-item label="请选择要删除数据的日期:" prop="startTime">
  290. <el-date-picker ref="startTime" v-model="deleteTemp.startTime" :clearable="false" type="date" placeholder="日期" style="width:100%px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" />
  291. </el-form-item>
  292. </el-col>
  293. </el-row>
  294. </el-form>
  295. <div slot="footer" class="dialog-footer">
  296. <el-button type="primary" :disabled="isokDisable" @click="deleteData()">确认</el-button>
  297. <el-button @click="dialogFormDelete = false;get_table_data()">关闭</el-button>
  298. </div>
  299. </el-dialog>
  300. <!-- 折线图 -->
  301. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogECharts" :close-on-click-modal="false" width="80%">
  302. <div>
  303. <h3 style="text-align: center;">月总用量: {{mountTotal}} 度</h3>
  304. <div id="chart7" style="width: 100%;height:400px;" />
  305. </div>
  306. <div slot="footer" class="dialog-footer">
  307. <!-- <el-button type="primary" :disabled="isokDisable" @click="deleteData()">确认</el-button> -->
  308. <el-button @click="dialogECharts = false">关闭</el-button>
  309. </div>
  310. </el-dialog>
  311. </div>
  312. </template>
  313. <script>
  314. // 引入
  315. require('script-loader!file-saver')
  316. import echarts from 'echarts'
  317. import { GetDataByName, GetDataByNames, PostDataByName, checkButtons, ExecDataByConfig, GetAccount,GetReportform ,getJson} from '@/api/common'
  318. // import { DownloadExcel, GetDataByNameXlsx } from '@/api/common'
  319. import waves from '@/directive/waves' // waves directive
  320. // eslint-disable-next-line no-unused-vars
  321. // import { isIntegerZero } from '@/utils/validate.js'
  322. import { parseTime, sortChange } from '@/utils/index.js'
  323. import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  324. import { MessageBox } from 'element-ui'
  325. import { getToken } from '@/utils/auth'
  326. import Cookies from 'js-cookie'
  327. export default {
  328. name: 'Elec',
  329. components: { Pagination },
  330. directives: { waves },
  331. data() {
  332. return {
  333. mountTotal:0,
  334. pastureName: Cookies.get('pasturename'),
  335. year: new Date().getFullYear(),
  336. month: new Date().getMonth() < 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1,
  337. selectionList:[],
  338. myHeight:document.documentElement.clientHeight - 85- 200,
  339. isokDisable: false,
  340. isElecAdd: [],
  341. isElecExport: [],
  342. isElecImport: [],
  343. isElecModify: [],
  344. tableKey: 0,
  345. list: null,
  346. total: 0,
  347. listLoading: true,
  348. formNumberSearchList: [],
  349. formNameSearchList: [],
  350. requestParam: {
  351. name: 'insertElectricity',
  352. offset: 0,
  353. pagecount: 0,
  354. parammaps: {}
  355. },
  356. postDataPramas: {
  357. },
  358. // 1-2:table&搜索传参
  359. getdataListParm: {
  360. name: 'getElecList',
  361. page: 1,
  362. offset: 1,
  363. pagecount: 50,
  364. returntype: 'Map',
  365. parammaps: {
  366. formName: '',
  367. formNumber: '',
  368. formType: '',
  369. pastureName: Cookies.get('pasturename'),
  370. departName: '',
  371. inputDatetime:[],
  372. startTime:'',
  373. stopTime:''
  374. }
  375. },
  376. // 2-3:下拉框请求后数据加入[]
  377. useTypes: [{ id: 0, name: '1级表' }, { id: 1, name: '2级表' }, { id: 2, name: '3级表' }],
  378. getDictByName: [],
  379. findAllAssetType: [],
  380. findAllPasture: [],
  381. findAllDepart: [],
  382. findAllEmploye: [],
  383. // 2-1.请求下拉框接口
  384. requestParams: [
  385. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['电表类型'] },
  386. { name: 'findAllAssetType', offset: 0, pagecount: 0, params: [] },
  387. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
  388. { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }}
  389. ],
  390. getDepartParam: {
  391. name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }
  392. },
  393. requestFilterParams: {
  394. name: 'getElecList',
  395. page: 1,
  396. offset: 1,
  397. pagecount: 50,
  398. returntype: 'Map',
  399. parammaps: { }
  400. },
  401. temp: { pastureName: '',
  402. consumption: '',
  403. measureId: '',
  404. useType: '',
  405. departName: '',
  406. aAmount: '',
  407. employeName1: '',
  408. endAmount: '',
  409. employeName: '',
  410. price1: '',
  411. note: '',
  412. formName: '',
  413. formNumber: '',
  414. rate: '',
  415. inputDatetime: parseTime(new Date(), '{y}-{m}-{d}'),
  416. typeName: '',
  417. assTypeId: '',
  418. employeId: this.$store.state.user.employeid,
  419. departmentId: this.$store.state.user.departmentid,
  420. pastureId: this.$store.state.user.pastureid
  421. },
  422. dialogFormVisible: false,
  423. dialogStatus: '',
  424. textMap: {
  425. update: '编辑',
  426. create: '新增',
  427. DosageRecord: '用量记录',
  428. delete: '删除',
  429. echarts: '每日用电量'
  430. },
  431. dialogFormDosageRecord: false,
  432. totalDosageRecord: 0,
  433. listDosageRecord: [],
  434. listLoadingDosageRecord: false,
  435. getDosageRecordListParm: {
  436. name: 'getAllMeasureTypeList',
  437. page: 1,
  438. offset: 1,
  439. pagecount: 50,
  440. returntype: 'Map',
  441. parammaps: {}
  442. },
  443. dosageRecordTemp: {},
  444. // 校验规则
  445. rules: {
  446. endAmount: [{ type: 'number', required: true, validator: (rule, value, callback) => {
  447. if (!value) {
  448. callback(new Error('不能为空'))
  449. }
  450. if (value < 0) {
  451. callback(new Error('必须大于0'))
  452. } else if (value < this.temp.aAmount) {
  453. callback(new Error('必须大于上次值'))
  454. }
  455. setTimeout(() => {
  456. const re = /^\d+$/ // /^[0-9]*[1-9][0-9]*$/
  457. const rsCheck = re.test(value)
  458. if (!rsCheck) {
  459. callback(new Error('请输入整数'))
  460. } else {
  461. callback()
  462. }
  463. }, 0)
  464. }, trigger: 'blur' }],
  465. equipmentName: [{ required: true, message: '必填', trigger: 'blur' }],
  466. price1: [{ required: true, message: '必填', trigger: 'blur' }],
  467. consumption: [{ required: true, message: '必填', trigger: 'blur' }],
  468. startTime: [{ required: true, message: '必填', trigger: 'blur' }]
  469. },
  470. MeasureListbyfilter: [],
  471. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  472. cellStyle: { padding: 0 + 'px' },
  473. buttons: [],
  474. isPercentage: false,
  475. percentage: 1,
  476. dialogFormDelete: false,
  477. deleteTemp: {},
  478. dialogECharts: false,
  479. isChart7: [],
  480. chart_data7: {},
  481. getChart7Parm: {
  482. name: 'getpSumNowWater',
  483. parammaps: {
  484. receiveTime: new Date().getFullYear(),
  485. pastureName: Cookies.get('pasturename'),
  486. startTime: "",
  487. endTime:""
  488. }
  489. },
  490. }
  491. },
  492. computed: {
  493. // 设置请求头
  494. headers() {
  495. return {
  496. // 设置token
  497. token: getToken()
  498. }
  499. },
  500. uploadData() {
  501. return {
  502. name: 'insertElecsMeasure',
  503. importParams: '牧场,表名称,表编号,上次抄表日期,上次值,抄表日期,用量(度),本次值,单价,录入人,备注',
  504. sheetname: 'SheetJS'
  505. }
  506. },
  507. // 设置上传地址
  508. uploadExcelUrl() {
  509. // process.env.VUE_APP_BASE_API是服务器的路径,也是axios的基本路径
  510. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  511. }
  512. },
  513. created() {
  514. const that = this
  515. GetDataByName({ 'name': 'getUserPCButtons', 'parammaps': { 'jwt_username': Cookies.get('name') }}).then(response => {
  516. that.buttons = response.data.list
  517. that.get_auto_buttons()
  518. })
  519. this.get_select_list()
  520. this.get_table_data()
  521. },
  522. methods: {
  523. // 电年度每月总用量
  524. // 各牧场年度用水量对比
  525. getChart1() {
  526. let date = new Date();
  527. let year = date.getFullYear()
  528. let month = date.getMonth() + 1
  529. let startTime = ''
  530. let endTime = ''
  531. let lastDay = new Date(year, month, 0).getDate();
  532. if(this.getdataListParm.parammaps.inputDatetime !== null && this.getdataListParm.parammaps.inputDatetime.length > 0){
  533. startTime = parseTime(this.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}') + '-01'
  534. endTime = parseTime(this.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}') + '-' + lastDay
  535. }else{
  536. startTime = parseTime(new Date(), '{y}-{m}') + '-01'
  537. endTime = parseTime(new Date(), '{y}-{m}') + '-' + lastDay
  538. }
  539. let datas = {
  540. name: "getPastureSumMonthElec",
  541. parammaps: {
  542. startTime: startTime,
  543. endTime: endTime,
  544. pastureName: this.pastureName.toString(),
  545. },
  546. }
  547. GetReportform(datas).then(response => {
  548. console.log('牧场每月用水量', response)
  549. if (response.data) {
  550. this.mountTotal = response.data.chart_data.nowYear[0][0]
  551. }else{
  552. this.mountTotal = 0;
  553. }
  554. })
  555. },
  556. // 折线图
  557. formEchart() {
  558. this.dialogECharts = true;
  559. this.dialogStatus = 'echarts'
  560. this.getChart7();
  561. },
  562. // XX月每日用电量
  563. getChart7() {
  564. if(this.getdataListParm.parammaps.inputDatetime !== null && this.getdataListParm.parammaps.inputDatetime.length > 0){
  565. this.getChart7Parm.parammaps.startTime = parseTime(this.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}')
  566. this.getChart7Parm.parammaps.endTime = parseTime(this.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}')
  567. this.getChart7Parm.parammaps.date = parseTime(this.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}')
  568. }else{
  569. this.getChart7Parm.parammaps.startTime = ''
  570. this.getChart7Parm.parammaps.endTime = ''
  571. this.getChart7Parm.parammaps.date = parseTime(new Date(), '{y}-{m}')
  572. }
  573. this.getChart1();
  574. let data = {
  575. name:"getPastureSumDayElec",
  576. parammaps:{
  577. startTime: this.getChart7Parm.parammaps.startTime || parseTime(new Date(), '{y}-{m}'),
  578. endTime: this.getChart7Parm.parammaps.endTime || parseTime(new Date(), '{y}-{m}'),
  579. pastureName: this.getdataListParm.parammaps.pastureName || Cookies.get('pasturename'),
  580. },
  581. }
  582. GetReportform(data).then(response => {
  583. console.log('XX月每日用电量==>图8', response)
  584. // this.chart_data7 = response.data.chart_data
  585. if(response.data){
  586. this.chart_data7 = {
  587. data1:response.data.chart_data.nowYear,
  588. data_name:this.pastureName,
  589. xdata:response.data.chart_data.day
  590. }
  591. }else{
  592. this.chart_data7 = {
  593. data1:[],
  594. data_name:[],
  595. xdata:[]
  596. }
  597. }
  598. this.roadChart7(this.chart_data7)
  599. })
  600. },
  601. // XX月每日用电量
  602. roadChart7(chart_data) {
  603. console.log(chart_data,'chart_data')
  604. if (this.chart7 != null) {
  605. this.chart7.dispose()
  606. }
  607. this.chart7 = echarts.init(document.getElementById('chart7'))
  608. var text = this.getChart7Parm.parammaps.date + '月每日用电量'
  609. var option = {
  610. title: { text: text, left:'left',textStyle: { color: '#769cfc' }},
  611. tooltip: { trigger: 'axis' },
  612. legend: {
  613. data: chart_data.data_name,
  614. left: 40,
  615. bottom:0
  616. },
  617. color: ['#eb123a','#eba612','#124feb','#15ab2e','#b20fdb'],
  618. grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
  619. xAxis: [{ type: 'category', name: '日',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
  620. yAxis: [{ type: 'value', name: '电量(度)'}],
  621. series: (function() {
  622. var serie = []
  623. if(chart_data.data1 !== null){
  624. for (var i = 0; i < chart_data.data1.length; i++) {
  625. var item = {
  626. name: chart_data.data_name && chart_data.data_name[i] ||'',
  627. type: 'line',
  628. data: chart_data.data1[i]
  629. }
  630. serie.push(item)
  631. }
  632. }
  633. return serie
  634. }())
  635. }
  636. this.chart7.setOption(option)
  637. window.onresize = function() {
  638. this.chart7.resize()
  639. }
  640. var that = this
  641. this.chart7.on('click', function(param, i) {
  642. // console.log(param)
  643. })
  644. },
  645. tableSort1(column) {
  646. sortChange(column, this.list)
  647. },
  648. tableSort2(column) {
  649. sortChange(column, this.listDosageRecord)
  650. },
  651. get_auto_buttons() {
  652. // 新增
  653. const ElecAdd = 'cost:elec:add'
  654. const isElecAdd = checkButtons(this.$store.state.user.buttons, ElecAdd)
  655. this.isElecAdd = isElecAdd
  656. // 导出
  657. const ElecExport = 'cost:elec:export'
  658. const isElecExport = checkButtons(this.$store.state.user.buttons, ElecExport)
  659. this.isElecExport = isElecExport
  660. // 导入
  661. const ElecImport = 'cost:elec:import'
  662. const isElecImport = checkButtons(this.$store.state.user.buttons, ElecImport)
  663. this.isElecImport = isElecImport
  664. // 编辑
  665. const ElecModify = 'cost:elec:modify'
  666. const isElecModify = checkButtons(this.$store.state.user.buttons, ElecModify)
  667. this.isElecModify = isElecModify
  668. },
  669. isIntegerZero_(rule, value, callback) {
  670. if (value === '' || value === undefined || value === null) {
  671. return callback(new Error('输入不可以为空'))
  672. }
  673. if (value.length === 0) {
  674. return callback(new Error('输入不可以为空'))
  675. }
  676. setTimeout(() => {
  677. const re = /^\d+$/ // /^[0-9]*[1-9][0-9]*$/
  678. const rsCheck = re.test(value)
  679. if (!rsCheck) {
  680. callback(new Error('请输入整数'))
  681. } else {
  682. callback()
  683. }
  684. }, 0)
  685. },
  686. handleDownloadTemp(){
  687. this.$alert('电表模板正在导出中,请勿刷新或离开本页面,若导出时间过长,建议缩小导出数据范围重新导出', {})
  688. this.isPercentage = true
  689. this.percentage = 1
  690. var timer = setInterval(() => {
  691. this.percentage += 5
  692. if (this.percentage > 95) {
  693. this.percentage = 99
  694. clearInterval(timer)
  695. }
  696. this.percentage = this.percentage
  697. }, 1000)
  698. this.requestParam.name = 'getMeasureList'
  699. this.requestParam.parammaps.pastureName = this.getdataListParm.parammaps.pastureName
  700. // this.requestParam.parammaps.departName = this.getdataListParm.parammaps.departName
  701. // this.requestParam.parammaps.formName = this.getdataListParm.parammaps.formName
  702. // this.requestParam.parammaps.formNumber = this.getdataListParm.parammaps.formNumber
  703. // this.requestParam.parammaps.useType = this.getdataListParm.parammaps.formType
  704. // this.requestParam.parammaps.startTime = this.getdataListParm.parammaps.startTime
  705. // this.requestParam.parammaps.stopTime = this.getdataListParm.parammaps.stopTime
  706. this.requestParam.parammaps.formType = '电表'
  707. GetDataByName(this.requestParam).then(response => {
  708. if (response.data.list !== '') {
  709. this.percentage = 99
  710. setTimeout(() => {
  711. this.isPercentage = false
  712. }, 2000)
  713. }
  714. this.$nextTick(() => {
  715. import('@/vendor/Export2Excel').then(excel => {
  716. let day = parseTime(new Date(), '{y}-{m}-{d}')
  717. for(let i=0;i<response.data.list.length;i++){
  718. this.$set(response.data.list[i], 'i', i+1)
  719. this.$set(response.data.list[i], 'day', day)
  720. this.$set(response.data.list[i], 'name', Cookies.get('employename'))
  721. }
  722. const list1 = response.data.list
  723. const tHeader = [
  724. '编号', '牧场', '表名称', '表编号', '抄表日期', '用量(度)', '单价', '录入人', '备注'
  725. ]
  726. const filterVal = [
  727. 'i', 'pastureName', 'formName', 'formNumber', 'day', '用量111', 'price', 'name', '备注2'
  728. ]
  729. const data1 = this.formatJson(filterVal, list1)
  730. excel.export_json_to_excel({
  731. header: tHeader,
  732. data: data1,
  733. filename: '电表模板',
  734. autoWidth: true,
  735. bookType: 'xlsx'
  736. })
  737. })
  738. })
  739. })
  740. },
  741. handleDownload() {
  742. this.$alert('电表正在导出中,请勿刷新或离开本页面,若导出时间过长,建议缩小导出数据范围重新导出', {})
  743. this.isPercentage = true
  744. this.percentage = 1
  745. var timer = setInterval(() => {
  746. this.percentage += 5
  747. if (this.percentage > 95) {
  748. this.percentage = 99
  749. clearInterval(timer)
  750. }
  751. this.percentage = this.percentage
  752. }, 1000)
  753. this.requestParam.name = 'meteringOutfit'
  754. this.requestParam.parammaps.pastureName = this.getdataListParm.parammaps.pastureName
  755. this.requestParam.parammaps.departName = this.getdataListParm.parammaps.departName
  756. this.requestParam.parammaps.formName = this.getdataListParm.parammaps.formName
  757. this.requestParam.parammaps.formNumber = this.getdataListParm.parammaps.formNumber
  758. this.requestParam.parammaps.useType = this.getdataListParm.parammaps.formType
  759. this.requestParam.parammaps.startTime = this.getdataListParm.parammaps.startTime
  760. this.requestParam.parammaps.stopTime = this.getdataListParm.parammaps.stopTime
  761. this.requestParam.parammaps.formType = '电表'
  762. GetAccount(this.requestParam).then(response => {
  763. if (response.data.list !== '') {
  764. this.percentage = 99
  765. setTimeout(() => {
  766. this.isPercentage = false
  767. }, 2000)
  768. }
  769. this.$nextTick(() => {
  770. import('@/vendor/Export2Excel').then(excel => {
  771. const list1 = response.data.list
  772. const tHeader = [
  773. '编号', '牧场', '表名称', '表编号', '抄表日期', '用量(度)', '单价', '录入人', '备注'
  774. ]
  775. const filterVal = [
  776. '编号', '牧场', '表名称', '表编号', '抄表日期2', '用量', '单价2', '录入人', '备注2'
  777. ]
  778. const data1 = this.formatJson(filterVal, list1)
  779. excel.export_json_to_excel({
  780. header: tHeader,
  781. data: data1,
  782. filename: '电表',
  783. autoWidth: true,
  784. bookType: 'xlsx'
  785. })
  786. })
  787. })
  788. })
  789. },
  790. formatJson(filterVal, jsonData) {
  791. return jsonData.map(v =>
  792. filterVal.map(j => {
  793. if (j === 'timestamp') {
  794. return parseTime(v[j])
  795. } else {
  796. return v[j]
  797. }
  798. })
  799. )
  800. },
  801. beforeImportExcel(file) {
  802. const isLt2M = file.size / 1024 / 1024 < 2
  803. if (!isLt2M) {
  804. this.$message.error('上传文件大小不能超过 2MB!')
  805. }
  806. return isLt2M
  807. },
  808. handleImportExcelSuccess(res, file) {
  809. this.get_table_data()
  810. if (res.msg === 'ok') {
  811. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  812. if (res.data.err_count > 0) {
  813. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  814. import('@/vendor/Export2Excel').then(excel => {
  815. const list1 = res.data.result
  816. const tHeader = [
  817. '编号', '牧场', '表名称', '表编号', '抄表日期', '用量', '单价', '录入人', '备注', '错误信息'
  818. ]
  819. const filterVal = [
  820. '编号', '牧场', '表名称', '表编号', '抄表日期', '用量', '单价', '录入人', '备注', 'error_msg'
  821. ]
  822. const data1 = this.formatJson(filterVal, list1)
  823. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '电表导入报错信息', autoWidth: true, bookType: 'xlsx' })
  824. })
  825. }
  826. } else {
  827. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  828. }
  829. },
  830. formNumberSearch(queryString, cb) {
  831. this.requestFilterParams.name = 'getMeasureListbyfilter'
  832. this.requestFilterParams.parammaps['formType'] = '电表'
  833. this.requestFilterParams.parammaps['pastureId'] = Cookies.get('pastureid')
  834. this.requestFilterParams.parammaps['formNumber'] = queryString
  835. this.requestFilterParams.parammaps['formName'] = ''
  836. GetDataByName(this.requestFilterParams).then(response => {
  837. if (response.data.list === null) {
  838. this.formNumberSearchList = []
  839. } else {
  840. this.formNumberSearchList = response.data.list
  841. }
  842. var results = queryString ? this.formNumberSearchList.filter(this.createFilter(queryString)) : this.formNumberSearchList
  843. cb(results)
  844. })
  845. },
  846. createFilter(queryString) {
  847. return returnValue => {
  848. return (
  849. returnValue.formNumber.toLowerCase().indexOf(queryString.toLowerCase()) >= 0
  850. )
  851. }
  852. },
  853. formNameSearch(queryString, cb) {
  854. this.requestFilterParams.name = 'getMeasureListbyfilter'
  855. this.requestFilterParams.parammaps['formType'] = '电表'
  856. this.requestFilterParams.parammaps['pastureId'] = Cookies.get('pastureid')
  857. this.requestFilterParams.parammaps['formNumber'] = ''
  858. this.requestFilterParams.parammaps['formName'] = queryString
  859. GetDataByName(this.requestFilterParams).then(response => {
  860. if (response.data.list === null) {
  861. this.formNameSearchList = []
  862. } else {
  863. this.formNameSearchList = response.data.list
  864. }
  865. var results = queryString ? this.formNameSearchList.filter(this.createFilterName(queryString)) : this.formNameSearchList
  866. cb(results)
  867. })
  868. },
  869. createFilterName(queryString) {
  870. return returnValue => {
  871. return (
  872. returnValue.formName.toLowerCase().indexOf(queryString.toLowerCase()) >= 0
  873. )
  874. }
  875. },
  876. handleformNumberSelect() {
  877. this.requestFilterParams.name = 'findByNMeasureElec'
  878. this.requestFilterParams.parammaps['formNumber'] = this.temp.formNumber
  879. this.requestFilterParams.parammaps['formName'] = ''
  880. GetDataByName(this.requestFilterParams).then(response => {
  881. this.$nextTick(() => {
  882. if (response.data.list.length > 0) {
  883. this.temp.pastureName = response.data.list[0].pastureName
  884. this.temp.useType = response.data.list[0].useType
  885. this.temp.departName = response.data.list[0].departName
  886. this.temp.aAmount = response.data.list[0].aAmount
  887. this.temp.employeName1 = response.data.list[0].employeName
  888. this.temp.formName = response.data.list[0].formName
  889. this.temp.measureId = response.data.list[0].measureId
  890. this.temp.pastureId = response.data.list[0].pastureId
  891. this.temp.rate = response.data.list[0].rate
  892. this.temp.price1 = response.data.list[0].price
  893. this.$forceUpdate()
  894. }
  895. })
  896. })
  897. },
  898. handleformNameSelect() {
  899. this.requestFilterParams.name = 'findByNMeasureElec'
  900. this.requestFilterParams.parammaps['formNumber'] = ''
  901. this.requestFilterParams.parammaps['formName'] = this.temp.formName
  902. GetDataByName(this.requestFilterParams).then(response => {
  903. this.$nextTick(() => {
  904. if (response.data.list.length > 0) {
  905. this.temp.pastureName = response.data.list[0].pastureName
  906. this.temp.useType = response.data.list[0].useType
  907. this.temp.departName = response.data.list[0].departName
  908. this.temp.aAmount = response.data.list[0].aAmount
  909. this.temp.employeName1 = response.data.list[0].employeName
  910. this.temp.formNumber = response.data.list[0].formNumber
  911. this.temp.measureId = response.data.list[0].measureId
  912. this.temp.pastureId = response.data.list[0].pastureId
  913. this.temp.price1 = response.data.list[0].price
  914. this.$forceUpdate()
  915. }
  916. })
  917. })
  918. },
  919. blurSelect(item) {
  920. this.temp.pastureName = ''
  921. this.temp.useType = ''
  922. this.temp.departName = ''
  923. this.temp.aAmount = ''
  924. this.temp.employeName1 = ''
  925. this.temp.formName = ''
  926. this.temp.formNumber = ''
  927. this.temp.measureId = ''
  928. this.temp.pastureId = ''
  929. this.temp.rate = ''
  930. },
  931. // 1-1: table&搜索
  932. get_table_data() {
  933. this.listLoading = true
  934. if(this.getdataListParm.parammaps.inputDatetime !== null && this.getdataListParm.parammaps.inputDatetime.length > 0){
  935. this.getdataListParm.parammaps.startTime = parseTime(this.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  936. this.getdataListParm.parammaps.stopTime = parseTime(this.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  937. }else{
  938. this.getdataListParm.parammaps.inputDatetime = []
  939. this.getdataListParm.parammaps.startTime = ''
  940. this.getdataListParm.parammaps.stopTime = ''
  941. }
  942. GetDataByName(this.getdataListParm).then(response => {
  943. if (response.data.list == null) {
  944. this.list = []
  945. this.total = 0
  946. } else {
  947. this.list = response.data.list
  948. this.pageNum = response.data.pageNum
  949. this.pageSize = response.data.pageSize
  950. this.total = response.data.total
  951. }
  952. setTimeout(() => {
  953. this.listLoading = false
  954. }, 100)
  955. })
  956. },
  957. // 2-2:下拉框
  958. get_select_list() {
  959. GetDataByNames(this.requestParams).then(response => {
  960. this.getDictByName = response.data.getDictByName.list
  961. this.findAllAssetType = response.data.findAllAssetType.list
  962. this.findAllPasture = response.data.findAllPasture.list
  963. this.findAllEmploye = response.data.findAllEmploye.list
  964. this.getDepartDownList()
  965. })
  966. },
  967. getDepartDownList() {
  968. GetDataByName(this.getDepartParam).then(response => {
  969. this.findAllDepart = response.data.list
  970. })
  971. },
  972. changePastureName(item) {
  973. this.getDepartParam.parammaps.pastureId = this.findAllPasture.find(obj => obj.name == item).id
  974. this.getdataListParm.parammaps.departName = ''
  975. // this.getdataListParm.parammaps.pastureName = item
  976. this.getdataListParm.parammaps.pastureName = item
  977. this.getDepartDownList()
  978. },
  979. form_search() {
  980. this.listLoading = true
  981. this.getdataListParm.offset = 1
  982. if(this.getdataListParm.parammaps.createDate == null){
  983. this.getdataListParm.parammaps.createDate =''
  984. }
  985. this.get_table_data()
  986. },
  987. handleModifyStatus(row, status) {
  988. this.$message({
  989. message: '操作成功',
  990. type: 'success'
  991. })
  992. row.status = status
  993. },
  994. form_reset() {
  995. this.temp.pastureName = ''
  996. this.temp.useType = ''
  997. this.temp.departName = ''
  998. this.temp.aAmount = ''
  999. this.temp.employeName1 = ''
  1000. this.temp.formName = ''
  1001. this.temp.formNumber = ''
  1002. this.temp.consumption = ''
  1003. this.temp.rate = ''
  1004. this.temp.endAmount = ''
  1005. this.temp.price1 = ''
  1006. this.temp.note = ''
  1007. this.temp.employeId = ''
  1008. this.temp.employeName = ''
  1009. this.temp.date = parseTime(new Date(), '{y}-{m}-{d}')
  1010. this.temp.inputDatetime = parseTime(new Date(), '{y}-{m}-{d}')
  1011. this.temp.typeName = ''
  1012. this.temp.assTypeId = ''
  1013. this.temp.employeId = this.$store.state.user.employeid
  1014. this.temp.departmentId = this.$store.state.user.departmentid
  1015. this.temp.pastureId = this.$store.state.user.pastureid
  1016. },
  1017. form_add() {
  1018. this.form_reset()
  1019. this.dialogStatus = 'create'
  1020. this.dialogFormVisible = true
  1021. this.temp.employeId = this.$store.state.user.employeid
  1022. this.$nextTick(() => {
  1023. this.$refs['temp'].clearValidate()
  1024. })
  1025. },
  1026. // 用量
  1027. handleBlurConsumption() {
  1028. if (this.dialogStatus == 'create') {
  1029. if (this.temp.aAmount !== '' && this.temp.consumption !== undefined && this.temp.consumption !== '' && this.temp.consumption !== null) {
  1030. this.temp.endAmount = parseFloat(this.temp.aAmount) + parseFloat(this.temp.consumption)
  1031. }
  1032. } else {
  1033. this.$set(this.temp, 'endAmount', parseFloat(this.temp.aAmount) + parseFloat(this.temp.consumption))
  1034. this.$forceUpdate()
  1035. }
  1036. },
  1037. // 当前值
  1038. handleBlurEndAmount() {
  1039. if (this.dialogStatus == 'create') {
  1040. if (this.temp.endAmount !== 'undefined' && this.temp.endAmount !== '' && this.temp.endAmount !== null && this.temp.aAmount !== '') {
  1041. this.temp.consumption = parseFloat(this.temp.endAmount) - parseFloat(this.temp.aAmount)
  1042. }
  1043. } else {
  1044. this.$set(this.temp, 'consumption', parseFloat(this.temp.endAmount) - parseFloat(this.temp.aAmount))
  1045. this.$forceUpdate()
  1046. }
  1047. },
  1048. add_dialog_save() {
  1049. this.isokDisable = true
  1050. setTimeout(() => {
  1051. this.isokDisable = false
  1052. }, 1000)
  1053. this.$refs['temp'].validate(valid => {
  1054. if (valid) {
  1055. this.postDataPramas.common = { 'returnmap': '0' }
  1056. this.postDataPramas.data = []
  1057. this.postDataPramas.data[0] = { 'name': 'checkMeasure', 'type': 'v', 'parammaps': { 'endAmount': this.temp.endAmount,
  1058. 'checkdate': this.temp.inputDatetime, 'measureId': this.temp.measureId }}
  1059. this.postDataPramas.data[1] = { 'name': 'insertElecExecData', 'type': 'e', 'parammaps': {
  1060. 'endAmount': this.temp.endAmount,
  1061. 'measureId': this.temp.measureId,
  1062. // 'data': this.temp.inputDatetime,
  1063. 'id': this.temp.id,
  1064. 'employeId': this.temp.employeId,
  1065. 'formNumber': this.temp.formNumber,
  1066. 'formName': this.temp.formName,
  1067. 'price': this.temp.price1,
  1068. 'rate': this.temp.rate,
  1069. 'pastureId': this.temp.pastureId,
  1070. 'note': this.temp.note,
  1071. 'consumption': this.temp.consumption
  1072. }}
  1073. this.postDataPramas.data[2] = { 'name': 'updateMeasureExecData', 'type': 'e',
  1074. 'parammaps': {
  1075. 'endAmount': this.temp.endAmount,
  1076. 'measureId': this.temp.measureId,
  1077. 'endDate': this.temp.inputDatetime,
  1078. 'lastRecodeId': '@insertElecExecData.LastInsertId'
  1079. }}
  1080. ExecDataByConfig(this.postDataPramas).then(response => {
  1081. console.log('保存发送参数', this.postDataPramas)
  1082. if (response.msg === 'fail') {
  1083. this.$notify({
  1084. title: '保存失败',
  1085. message: response.data,
  1086. type: 'warning',
  1087. duration: 2000
  1088. })
  1089. } else {
  1090. this.get_table_data()
  1091. this.dialogFormVisible = false
  1092. this.$notify({
  1093. title: '',
  1094. message: '保存成功',
  1095. type: 'success',
  1096. duration: 2000
  1097. })
  1098. }
  1099. })
  1100. }
  1101. })
  1102. },
  1103. // 继续新增
  1104. add_dialog_save_again() {
  1105. this.isokDisable = true
  1106. setTimeout(() => {
  1107. this.isokDisable = false
  1108. }, 1000)
  1109. this.$refs['temp'].validate(valid => {
  1110. if (valid) {
  1111. this.postDataPramas.common = { 'returnmap': '0' }
  1112. this.postDataPramas.data = []
  1113. this.postDataPramas.data[0] = { 'name': 'checkMeasure', 'type': 'v', 'parammaps': { 'endAmount': this.temp.endAmount,
  1114. 'checkdate': this.temp.inputDatetime, 'measureId': this.temp.measureId }}
  1115. this.postDataPramas.data[1] = { 'name': 'insertElecExecData', 'type': 'e', 'parammaps': {
  1116. 'endAmount': this.temp.endAmount,
  1117. 'measureId': this.temp.measureId,
  1118. // 'data': this.temp.inputDatetime,
  1119. 'id': this.temp.id,
  1120. 'employeId': this.temp.employeId,
  1121. 'formNumber': this.temp.formNumber,
  1122. 'formName': this.temp.formName,
  1123. 'price': this.temp.price1,
  1124. 'rate': this.temp.rate,
  1125. 'pastureId': this.temp.pastureId,
  1126. 'note': this.temp.note,
  1127. 'consumption': this.temp.consumption
  1128. }}
  1129. this.postDataPramas.data[2] = { 'name': 'updateMeasureExecData', 'type': 'e',
  1130. 'parammaps': {
  1131. 'endAmount': this.temp.endAmount,
  1132. 'measureId': this.temp.measureId,
  1133. 'endDate': this.temp.inputDatetime,
  1134. 'lastRecodeId': '@insertElecExecData.LastInsertId'
  1135. }}
  1136. ExecDataByConfig(this.postDataPramas).then(response => {
  1137. console.log('保存发送参数', this.postDataPramas)
  1138. if (response.msg === 'fail') {
  1139. this.$notify({
  1140. title: '保存失败',
  1141. message: response.data,
  1142. type: 'warning',
  1143. duration: 2000
  1144. })
  1145. } else {
  1146. this.form_reset()
  1147. this.$notify({
  1148. title: '',
  1149. message: '保存成功',
  1150. type: 'success',
  1151. duration: 2000
  1152. })
  1153. }
  1154. })
  1155. }
  1156. })
  1157. },
  1158. form_edit(row) {
  1159. console.log(row,'编剧')
  1160. this.temp = Object.assign({}, row) // copy obj
  1161. // if (this.temp.endAmount !== '' && this.temp.endAmount !== undefined && this.temp.endAmount !== null && this.temp.aAmount !== '' && this.temp.aAmount !== undefined && this.temp.aAmount !== null) {
  1162. // this.$set(this.temp, 'consumption', parseFloat(this.temp.endAmount) - parseFloat(this.temp.aAmount))
  1163. // }
  1164. this.temp.date = row.dateFormat;
  1165. this.dialogStatus = 'update'
  1166. this.dialogFormVisible = true
  1167. this.$nextTick(() => {
  1168. this.$refs['temp'].clearValidate()
  1169. })
  1170. },
  1171. edit_dialog_save() {
  1172. this.$refs['temp'].validate(valid => {
  1173. if (valid) {
  1174. this.temp.date = parseTime(new Date(), '{y}-{m}-{d}')
  1175. this.postDataPramas.common = { 'returnmap': '0' }
  1176. this.postDataPramas.data = []
  1177. this.postDataPramas.data[0] = { 'name': 'checkMeasureUpdate', 'type': 'v', 'parammaps': { 'endAmount': this.temp.endAmount,
  1178. 'checkdate': this.temp.date, 'measureId': this.temp.measureId }}
  1179. this.postDataPramas.data[1] = { 'name': 'updateElectricity', 'type': 'e', 'parammaps': {
  1180. 'endAmount': this.temp.endAmount,
  1181. 'measureId': this.temp.measureId,
  1182. // 'data': this.temp.inputDatetime,
  1183. 'rate': this.temp.rate,
  1184. 'id': this.temp.id,
  1185. 'note': this.temp.note,
  1186. 'employeId': this.temp.employeId,
  1187. 'consumption': this.temp.consumption
  1188. }}
  1189. this.postDataPramas.data[2] = { 'name': 'updateMeasureEle', 'type': 'e',
  1190. 'parammaps': {
  1191. 'endAmount': this.temp.endAmount,
  1192. 'measureId': this.temp.measureId,
  1193. 'endDate': this.temp.date,
  1194. 'lastRecodeId': this.temp.id
  1195. }}
  1196. ExecDataByConfig(this.postDataPramas).then(response => {
  1197. if (response.msg === 'fail') {
  1198. this.$notify({
  1199. title: '保存失败',
  1200. message: response.data,
  1201. type: 'warning',
  1202. duration: 2000
  1203. })
  1204. } else {
  1205. this.get_table_data()
  1206. this.dialogFormVisible = false
  1207. this.$notify({
  1208. title: '',
  1209. message: '保存成功',
  1210. type: 'success',
  1211. duration: 2000
  1212. })
  1213. }
  1214. })
  1215. }
  1216. })
  1217. },
  1218. form_delete() {
  1219. this.deleteTemp = {}
  1220. this.dialogStatus = 'delete'
  1221. this.dialogFormDelete = true
  1222. },
  1223. deleteData() {
  1224. this.$refs['deleteTemp'].validate(valid => {
  1225. if (valid) {
  1226. this.requestParam.name = 'deletedatastem'
  1227. this.requestParam.parammaps = {}
  1228. this.requestParam.parammaps.pastureName = this.getdataListParm.parammaps.pastureName
  1229. this.requestParam.parammaps.codeType = 2
  1230. this.requestParam.parammaps.startTime = this.deleteTemp.startTime
  1231. this.requestParam.parammaps.stopTime = this.deleteTemp.startTime
  1232. PostDataByName(this.requestParam).then(response => {
  1233. if (response.msg == 'fail') {
  1234. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1235. } else {
  1236. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1237. this.dialogFormDelete = false
  1238. this.get_table_data()
  1239. }
  1240. })
  1241. }
  1242. })
  1243. },
  1244. handleDosageRecord(row) {
  1245. this.dialogStatus = 'DosageRecord'
  1246. this.dialogFormDosageRecord = true
  1247. this.dosageRecordTemp = Object(row, {})
  1248. this.getDosageRecordList()
  1249. },
  1250. getDosageRecordList() {
  1251. this.listLoadingDosageRecord = true
  1252. this.getDosageRecordListParm.parammaps.id = this.dosageRecordTemp.measureId
  1253. GetDataByName(this.getDosageRecordListParm).then(response => {
  1254. this.listDosageRecord = response.data.list
  1255. this.pageNumDosageRecord = response.data.pageNum
  1256. this.pageSizeDosageRecord = response.data.pageSize
  1257. if (response.data.total) {
  1258. this.totalDosageRecord = response.data.total
  1259. }
  1260. setTimeout(() => {
  1261. this.listLoadingDosageRecord = false
  1262. }, 100)
  1263. })
  1264. }
  1265. }
  1266. }
  1267. </script>