index.vue 43 KB

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