index.vue 53 KB

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