index.vue 42 KB

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