index.vue 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <el-select v-model="getdataListParm.parammaps.pastureName" placeholder="牧场" class="filter-item" @change="changePastureName">
  5. <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
  6. </el-select>
  7. <el-select v-model="getdataListParm.parammaps.departmentName" clearable placeholder="部门" class="filter-item">
  8. <el-option v-for="item in findAllDepart" :key="item.id" :label="item.name" :value="item.name" />
  9. </el-select>
  10. <el-autocomplete ref="cardNumber" v-model="getdataListParm.parammaps.cardNumber" style="width:300px" value-key="cardNumber" class="inline-input filter-item" :fetch-suggestions="cardNumberSearch" placeholder="请选择油卡编号" @select="handlecardNumberSelect">
  11. <template slot-scope="{ item }">
  12. <div class="name" style="display: inline;">{{ item.cardNumber }}</div>
  13. </template>
  14. </el-autocomplete>
  15. <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
  16. <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
  17. <el-button class="filter-item" style="margin-left: 10px;display: inline-block;" type="info" icon="el-icon-tickets" @click="handleDownloadTemp"> 模板 </el-button>
  18. <el-button v-if="isOtherinfoExport" class="filter-item" type="success" style="margin-left: 10px;" icon="el-icon-download" @click="handleDownload">导出</el-button>
  19. <el-upload :headers="headers" style="margin-left: 10px;display: inline-block;" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImportExcel" :on-success="handleImportExcelSuccess">
  20. <el-button v-waves class="filter-item" type="warning" icon="el-icon-download">导入</el-button>
  21. </el-upload>
  22. </div>
  23. <el-table
  24. :key="tableKey"
  25. v-loading="listLoading"
  26. element-loading-text="给我一点时间"
  27. :data="list"
  28. border
  29. fit
  30. highlight-current-row
  31. style="width: 100%;"
  32. :row-style="rowStyle"
  33. :cell-style="cellStyle"
  34. class="elTable"
  35. @sort-change="tableSort"
  36. :max-height="myHeight"
  37. >
  38. <el-table-column label="序号" align="center" type="index" width="50px">
  39. <template slot-scope="scope">
  40. <span>{{ scope.$index + (pageNum-1) * pageSize + 1 }}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="牧场" min-width="110px" align="center" prop="pastureName" />
  44. <el-table-column label="部门" min-width="110px" align="center" prop="departmentName" />
  45. <el-table-column label="油卡编号" min-width="110px" align="center" prop="cardNumber" />
  46. <el-table-column label="油卡类型" min-width="110px" align="center" prop="cardType" />
  47. <el-table-column label="剩余余额" min-width="110px" align="center" sortable prop="cardAmount" />
  48. <el-table-column label="设备编号" min-width="110px" align="center" prop="assetNumber" />
  49. <el-table-column label="设备名称" min-width="110px" align="center" prop="assetName" />
  50. <el-table-column label="油卡状态" min-width="110px" align="center" prop="assetName">
  51. <template slot-scope="scope">
  52. <span v-if="scope.row.enable == 0">启用</span>
  53. <span v-else>停用</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="操作" align="center" width="350" class-name="small-padding fixed-width" fixed="right">
  57. <template slot-scope="{row}">
  58. <el-button v-if="row.enable == 0" type="success" size="mini" @click="form_edit(row)">编辑</el-button>
  59. <el-button type="success" size="mini" @click="handleChange(row)">变更记录</el-button>
  60. <el-button type="success" size="mini" @click="handleRecharge(row)">充值</el-button>
  61. <el-button v-if="row.enable == 0" type="danger" size="mini" @click="handleDisable(row)">停用</el-button>
  62. <el-button v-else type="danger" size="mini" @click="handleDisable(row)">启用</el-button>
  63. <el-button v-if="row.enable == 1" type="danger" size="mini" @click="form_delete(row)">删除</el-button>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. <pagination v-show="total>0" :total="total" :page.sync="getdataListParm.offset" :limit.sync="getdataListParm.pagecount" @pagination="get_table_data" />
  68. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false" width="50%">
  69. <el-form ref="temp" :rules="rules" :model="temp" label-position="right" label-width="100px" style="width: 800px; margin-left:50px;">
  70. <el-row>
  71. <el-col :span="12">
  72. <el-form-item label="卡号:" prop="cardNumber">
  73. <el-input ref="cardNumber" v-model="temp.cardNumber" :disabled="dialogStatus=='update'" />
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. <el-row>
  78. <el-col :span="12">
  79. <el-form-item label="设备:" prop="assetSum">
  80. <el-autocomplete ref="assetSum" v-model="temp.assetSum" style="width:300px" value-key="assetSum" class="inline-input" :fetch-suggestions="formNumberSearch" placeholder="请选择设备" @select="handleformNameSelect" @blur="blurformNameSelect">
  81. <template slot-scope="{ item }">
  82. <div class="name" style="display: inline;">{{ item.assetName }}</div>
  83. </template>
  84. </el-autocomplete>
  85. </el-form-item>
  86. </el-col>
  87. </el-row>
  88. <el-row>
  89. <el-col :span="12">
  90. <el-form-item label="牧场:" prop="pastureName">
  91. <el-input ref="pastureName" v-model="temp.pastureName" disabled />
  92. </el-form-item>
  93. </el-col>
  94. </el-row>
  95. <el-row>
  96. <el-col :span="12">
  97. <el-form-item label="部门:" prop="departmentName">
  98. <el-input ref="departmentName" v-model="temp.departmentName" disabled />
  99. </el-form-item>
  100. </el-col>
  101. </el-row>
  102. <el-row>
  103. <el-col :span="12">
  104. <el-form-item label="卡类型:" prop="cardType">
  105. <el-select ref="cardType" v-model="temp.cardType" placeholder="卡类型" style="width:100%;" disabled>
  106. <el-option v-for="item in cardTypeList" :key="item.id" :label="item.name" :value="item.name" />
  107. </el-select>
  108. </el-form-item>
  109. </el-col>
  110. </el-row>
  111. <el-row>
  112. <el-col :span="12">
  113. <el-form-item label="卡余额:" prop="cardAmount">
  114. <el-input ref="cardAmount" v-model="temp.cardAmount" />
  115. </el-form-item>
  116. </el-col>
  117. </el-row>
  118. </el-form>
  119. <div slot="footer" class="dialog-footer">
  120. <el-button v-if="dialogStatus==='create'" ref="createb" :disabled="isokDisable" type="success" @click="add_dialog_save_again()">保存并新增</el-button>
  121. <el-button type="primary" :disabled="isokDisable" @click="dialogStatus==='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
  122. <el-button @click="dialogFormVisible = false;get_table_data()">取消并关闭</el-button>
  123. </div>
  124. </el-dialog>
  125. <el-dialog :title="textMap[tabledialogStatus]" :visible.sync="changeFormVisible" :close-on-click-modal="false" width="50%">
  126. <el-table
  127. :key="tableKey"
  128. v-loading="changelistLoading"
  129. element-loading-text="给我一点时间"
  130. :data="changelist"
  131. border
  132. fit
  133. highlight-current-row
  134. style="width: 100%;"
  135. :row-style="rowStyle"
  136. :cell-style="cellStyle"
  137. class="elTable"
  138. >
  139. <el-table-column label="变更日期" align="center" sortable min-width="110px" prop="changeDate" />
  140. <el-table-column label="变更类型" align="center" min-width="110px" prop="changeType" />
  141. <el-table-column label="变更前设备" align="center" min-width="110px" prop="beforeMaintenance" />
  142. <el-table-column label="变更后设备" align="center" min-width="110px" prop="afterMaintenance" />
  143. <el-table-column label="变更人" align="center" min-width="110px" prop="empname" />
  144. </el-table>
  145. <h3 style="font-weight: 300;">{{ cardNumber }}-启停记录</h3>
  146. <el-table
  147. :key="tableKey2"
  148. v-loading="changelistLoading"
  149. element-loading-text="给我一点时间"
  150. :data="changelist2"
  151. border
  152. fit
  153. highlight-current-row
  154. style="width: 100%;"
  155. :row-style="rowStyle"
  156. :cell-style="cellStyle"
  157. class="elTable"
  158. >
  159. <el-table-column label="启停日期" align="center" sortable min-width="110px" prop="oildCardDate" />
  160. <el-table-column label="启停类型" align="center" min-width="110px" prop="statue" />
  161. <el-table-column label="操作人" align="center" min-width="110px" prop="personName" />
  162. </el-table>
  163. <div slot="footer" class="dialog-footer" style="bottom:10px">
  164. <el-button @click="changeFormVisible = false;get_table_data()">关闭</el-button>
  165. </div>
  166. </el-dialog>
  167. <el-dialog :title="textMap[tabledialogStatus]" :visible.sync="rechargeFormVisible" :close-on-click-modal="false" width="50%">
  168. <el-table
  169. :key="tableKey"
  170. v-loading="rechargelistLoading"
  171. element-loading-text="给我一点时间"
  172. :data="rechargelist"
  173. border
  174. fit
  175. highlight-current-row
  176. style="width: 100%;"
  177. :row-style="rowStyle"
  178. :cell-style="cellStyle"
  179. class="elTable"
  180. >
  181. <el-table-column label="日期" align="center" type="index" width="150px">
  182. <template slot-scope="scope">
  183. <span>{{ scope.row.dateFormat }}</span>
  184. </template>
  185. </el-table-column>
  186. <el-table-column label="卡号" min-width="110px" align="center">
  187. <template slot-scope="scope">
  188. <span>{{ scope.row.cardCode }}</span>
  189. </template>
  190. </el-table-column>
  191. <el-table-column label="充值金额" width="150px" align="center">
  192. <template slot-scope="scope">
  193. <span>{{ scope.row.rechargeNum }}</span>
  194. </template>
  195. </el-table-column>
  196. <el-table-column label="充值人" width="150px" align="center">
  197. <template slot-scope="scope">
  198. <span>{{ scope.row.empName }}</span>
  199. </template>
  200. </el-table-column>
  201. </el-table>
  202. <div slot="footer" class="dialog-footer" style="bottom:10px">
  203. <el-button v-if="rechargeTemp.enable == 0" type="success" @click="createRecharge()">充值</el-button>
  204. <el-button @click="rechargeFormVisible = false;get_table_data()">取消并关闭</el-button>
  205. </div>
  206. </el-dialog>
  207. <el-dialog :title="textMap[dialogStatus]" :visible.sync="rechargeFFormVisible" :close-on-click-modal="false" width="50%">
  208. <el-form ref="temp" :rules="rules" :model="temp" label-position="right" label-width="100px" style="width: 800px; margin-left:50px;">
  209. <el-row>
  210. <el-col :span="8">
  211. <el-form-item label="负责人:" prop="employeId">
  212. <el-select v-model="temp.employeId" placeholder="负责人" class="filter-item" style="width:100%;">
  213. <el-option v-for="item in findAllEmploye" :key="item.id" :label="item.name" :value="item.id" />
  214. </el-select>
  215. </el-form-item>
  216. </el-col>
  217. </el-row>
  218. <el-row>
  219. <el-col :span="8">
  220. <el-form-item label="当前时间:" prop="dateFormat" style="width:100%;">
  221. <el-date-picker v-model="temp.dateFormat" type="date" placeholder="当前时间" format="yyyy-MM-dd" value-format="yyyy-MM-dd" disabled style="width:100%;" />
  222. </el-form-item>
  223. </el-col>
  224. </el-row>
  225. <el-row>
  226. <el-col :span="8">
  227. <el-form-item label="充值金额" prop="rechargeNum" style="width:100%;">
  228. <el-input ref="rechargeNum" v-model="temp.rechargeNum" />
  229. </el-form-item>
  230. </el-col>
  231. </el-row>
  232. </el-form>
  233. <div slot="footer" class="dialog-footer">
  234. <el-button type="primary" @click="createRechargeData()">确认</el-button>
  235. <el-button @click="rechargeFFormVisible = false">取消并关闭</el-button>
  236. </div>
  237. </el-dialog>
  238. </div>
  239. </template>
  240. <script>
  241. // 引入
  242. import { GetDataByName, GetDataByNames, PostDataByName, getRecuData, ExecDataByConfig, failproccess,checkButtons } from '@/api/common'
  243. import waves from '@/directive/waves'
  244. import { parseTime, sortChange,json2excel } from '@/utils/index.js'
  245. import { validateEMail } from '@/utils/validate.js'
  246. import Pagination from '@/components/Pagination'
  247. import { MessageBox } from 'element-ui'
  248. import Cookies from 'js-cookie'
  249. import { getToken } from '@/utils/auth'
  250. export default {
  251. name: 'Otherinfo',
  252. components: { Pagination },
  253. directives: { waves },
  254. data() {
  255. return {
  256. myHeight:document.documentElement.clientHeight - 85- 200,
  257. isOtherinfoExport:[],
  258. buttons:[],
  259. isokDisable: false,
  260. tableKey: 0,
  261. tableKey2: 0,
  262. list: null,
  263. changelist: null,
  264. changelist2: null,
  265. rechargelist: null,
  266. total: 0,
  267. listLoading: true,
  268. changelistLoading: true,
  269. rechargelistLoading: true,
  270. formNumberSearchList: [],
  271. requestParam: {
  272. name: 'insertAsset',
  273. offset: 0,
  274. pagecount: 0,
  275. parammaps: {}
  276. },
  277. requestParam2: {},
  278. parentDept: [],
  279. getDeptParm: { name: 'getdeptrecu', idname: 'value', params: [-1] },
  280. postDataPramas: { },
  281. getdataListParm: {
  282. name: 'getOilcardList', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  283. parammaps: { pname: '', pastureName: Cookies.get('pasturename') }
  284. },
  285. requestFilterParams: {
  286. name: '', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  287. parammaps: {}
  288. },
  289. requestFilterParams2: {
  290. name: '', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  291. parammaps: {}
  292. },
  293. getchangedataListParm: {
  294. name: 'getOilcardHistory', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  295. parammaps: { }
  296. },
  297. getchangedataListParm2: {
  298. // name: 'getOilcardHistory', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  299. // parammaps: { }
  300. },
  301. getrechargedataListParm: {
  302. name: 'getrechargerecordList', page: 1, offset: 1, pagecount: 10, returntype: 'Map',
  303. parammaps: { }
  304. },
  305. cardTypeList: [{ name: '内部', id: '0' }],
  306. findAllProvider: [],
  307. findAllAssetType: [],
  308. findAllPasture: [],
  309. findAllDepart: [],
  310. findAllEmploye: [],
  311. getDictByName: [],
  312. findAllAsset: [],
  313. requestParams: [
  314. { name: 'findAllProvider', offset: 0, pagecount: 0, params: [] },
  315. { name: 'findAllAssetType', offset: 0, pagecount: 0, params: [] },
  316. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
  317. // { name: 'findAllDepart', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
  318. { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
  319. { name: 'findAllAsset', offset: 0, pagecount: 0, params: [] },
  320. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['资产状态'] }
  321. ],
  322. getDepartParam: { name: 'findAllDepart1', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid'), 'eId': Cookies.get('employeid') }},
  323. dataform: { deptId: '', parentId: '' },
  324. temp: {},
  325. dialogFormVisible: false,
  326. changeFormVisible: false,
  327. rechargeFormVisible: false,
  328. rechargeFFormVisible: false,
  329. tabledialogStatus: '',
  330. dialogStatus: '',
  331. textMap: { update: '编辑', create: '新增', change: '变更记录', recharge: '充值记录', changeF: '换卡', rechargeF: '充值' },
  332. dialogPvVisible: false,
  333. // 校验规则
  334. rules: {
  335. cardNumber: [{ required: true, message: '必填', trigger: 'blur' }],
  336. cardType: [{ required: true, message: '必填', trigger: 'blur' }],
  337. cardAmount: [{ required: true, message: '必填', trigger: 'blur' }]
  338. },
  339. rechargeTemp: {},
  340. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  341. cellStyle: { padding: 0 + 'px' },
  342. defaultProps: {
  343. children: 'children',
  344. label: 'label'
  345. },
  346. nodeKey: 'value',
  347. defaultCheckedKeys: [],
  348. cardNumber: '',
  349. isPercentage: false,
  350. percentage: 1,
  351. downLoadParm:{},
  352. downLoadList:[]
  353. }
  354. },
  355. computed: {
  356. // 设置请求头
  357. headers() {
  358. return {
  359. token: getToken()
  360. }
  361. },
  362. uploadData() {
  363. return {
  364. name: 'importOilcard',
  365. importParams: '牧场,车自编号,油卡,类型,上次用油量,部门',
  366. sheetname: 'SheetJS'
  367. }
  368. },
  369. // 设置上传地址
  370. uploadExcelUrl() {
  371. // process.env.VUE_APP_BASE_API是服务器的路径,也是axios的基本路径
  372. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  373. }
  374. },
  375. created() {
  376. const that = this
  377. GetDataByName({ 'name': 'getUserPCButtons', 'parammaps': { 'jwt_username': Cookies.get('name') }}).then(response => {
  378. that.buttons = response.data.list
  379. that.get_auto_buttons()
  380. })
  381. this.get_select_list()
  382. this.get_table_data()
  383. this.getDepartDownList()
  384. },
  385. methods: {
  386. get_auto_buttons() {
  387. // 导出
  388. const OtherinfoExport = 'basic:otherinfo:otherinfoExport'
  389. const isOtherinfoExport = checkButtons(this.buttons, OtherinfoExport)
  390. this.isOtherinfoExport = isOtherinfoExport
  391. },
  392. tableSort(column) {
  393. sortChange(column, this.list)
  394. },
  395. getDeptList() {
  396. getRecuData(this.getDeptParm).then(response => {
  397. this.parentDept = response.data
  398. })
  399. },
  400. popoverHide(checkedIds, checkedData) {
  401. this.dataform.deptId = checkedIds
  402. this.dataform.parentId = checkedData.parentid
  403. },
  404. providerSearch(queryString, cb) {
  405. var returnList = this.findAllProvider
  406. var results = queryString
  407. ? returnList.filter(this.createFilter(queryString))
  408. : returnList
  409. // 调用 callback 返回建议列表的数据
  410. cb(results)
  411. },
  412. createFilter(queryString) {
  413. return returnValue => {
  414. return (
  415. returnValue.assetName.toLowerCase().indexOf(queryString.toLowerCase()) >= 0
  416. )
  417. }
  418. },
  419. handleSelect(item) {
  420. console.log(item)
  421. },
  422. get_table_data() {
  423. this.listLoading = true
  424. GetDataByName(this.getdataListParm).then(response => {
  425. if (response.data.list !== null) {
  426. for (let i = 0; i < response.data.list.length; i++) {
  427. if (response.data.list[i].cardAmount !== undefined) {
  428. this.$set(response.data.list[i], 'cardAmount', parseFloat(response.data.list[i].cardAmount))
  429. }
  430. }
  431. this.list = response.data.list
  432. this.pageNum = response.data.pageNum
  433. this.pageSize = response.data.pageSize
  434. } else {
  435. this.list = []
  436. this.pageNum = 0
  437. this.pageSize = 0
  438. }
  439. this.total = response.data.total
  440. this.getDeptList()
  441. setTimeout(() => {
  442. this.listLoading = false
  443. }, 100)
  444. })
  445. },
  446. get_select_list() {
  447. this.requestParams[5].params[0] = this.$store.state.user.pastureid
  448. GetDataByNames(this.requestParams).then(response => {
  449. this.findAllProvider = response.data.findAllProvider.list
  450. this.findAllAssetType = response.data.findAllAssetType.list
  451. this.findAllPasture = response.data.findAllPasture.list
  452. // this.findAllDepart = response.data.findAllDepart.list
  453. this.findAllEmploye = response.data.findAllEmploye.list
  454. this.findAllAsset = response.data.findAllAsset.list
  455. this.getDictByName = response.data.getDictByName.list
  456. })
  457. },
  458. changePastureName(item) {
  459. this.getDepartParam.parammaps.pastureId = this.findAllPasture.find(obj => obj.name == item).id
  460. this.getdataListParm.parammaps.departmentId = ''
  461. this.getDepartDownList()
  462. },
  463. getDepartDownList() {
  464. GetDataByName(this.getDepartParam).then(response => {
  465. this.findAllDepart = response.data.list
  466. })
  467. },
  468. form_search() {
  469. this.listLoading = true
  470. this.getdataListParm.offset = 1
  471. this.get_table_data()
  472. },
  473. handleModifyStatus(row, status) {
  474. this.$message({ message: '操作成功', type: 'success' })
  475. row.status = status
  476. },
  477. form_reset() {
  478. this.temp = { inputDatetime: parseTime(new Date(), '{y}-{m}-{d}'), dateFormat: parseTime(new Date(), '{y}-{m}-{d}'), assetName: '', assetId: '', deptName: '', pastureName: '', pastureId: Cookies.get('pastureid'), cardNumber: '', cardType: '内部', cardAmount: '', rechargeNum: '' }
  479. },
  480. form_add() {
  481. this.form_reset()
  482. this.dialogStatus = 'create'
  483. this.dialogFormVisible = true
  484. this.$nextTick(() => {
  485. this.$refs['temp'].clearValidate()
  486. })
  487. },
  488. add_dialog_save() {
  489. this.$refs['temp'].validate(valid => {
  490. if (valid) {
  491. // 卡余额
  492. this.temp.cardAmount = parseFloat(this.temp.cardAmount).toFixed(2)
  493. console.log(this.requestParam, '000')
  494. this.requestParam = {}
  495. this.requestParam.common = { 'returnmap': '0' }
  496. this.requestParam.data = []
  497. if (this.temp.departmentId == undefined || this.temp.departmentId == '') {
  498. this.temp.departmentId = ''
  499. this.temp.departmentName = ''
  500. }
  501. if (this.temp.assetId == undefined || this.temp.assetId == '') {
  502. this.temp.assetId = ''
  503. this.temp.assetSum = ''
  504. }
  505. if (this.temp.pastureName == undefined || this.temp.pastureName == '') {
  506. this.temp.pastureName = Cookies.get('pasturename')
  507. }
  508. this.requestParam.data[0] = { 'name': 'checkOilcard', 'type': 'v', 'parammaps': {
  509. cardCode: this.temp.cardNumber,
  510. eqId: this.temp.assetId
  511. }}
  512. this.requestParam.data[1] = { 'name': 'insertOilcard', 'type': 'e', 'parammaps': {
  513. assetId: this.temp.assetId,
  514. assetName: this.temp.assetSum,
  515. cardAmount: this.temp.cardAmount,
  516. cardNumber: this.temp.cardNumber,
  517. cardType: this.temp.cardType,
  518. dateFormat: this.temp.dateFormat,
  519. departmentId: this.temp.departmentId,
  520. deptName: this.temp.departmentName,
  521. inputDatetime: this.temp.inputDatetime,
  522. pastureId: this.temp.pastureId,
  523. pastureName: this.temp.pastureName,
  524. rechargeNum: this.temp.rechargeNum
  525. }}
  526. if (this.temp.assetSum !== null && this.temp.assetSum !== undefined && this.temp.assetSum !== '') {
  527. this.requestParam.data[2] = { 'name': 'insertSpotList', 'resultmaps': { 'list': [{ changeType: '新增', beforeMaintenance: 0, afterMaintenance: this.temp.assetSum, changePersonId: Cookies.get('employeid') }] }}
  528. this.requestParam.data[2].children = []
  529. this.requestParam.data[2].children[0] = { 'name': 'insertOilcardHistory', 'type': 'e', 'parammaps': {
  530. oildcardId: '@insertOilcard.LastInsertId',
  531. changeType: '@insertSpotList.changeType',
  532. beforeMaintenance: '@insertSpotList.beforeMaintenance',
  533. afterMaintenance: '@insertSpotList.afterMaintenance',
  534. changePersonId: '@insertSpotList.changePersonId'
  535. }}
  536. }
  537. ExecDataByConfig(this.requestParam).then(response => {
  538. if (response.msg === 'fail') {
  539. this.$notify({ title: '失败', message: '保存失败-' + response.data, type: 'danger', duration: 2000 })
  540. } else {
  541. this.get_table_data()
  542. this.dialogFormVisible = false
  543. this.$notify({ title: '成功', message: '新增成功', type: 'success', duration: 2000 })
  544. }
  545. })
  546. }
  547. })
  548. },
  549. add_dialog_save_again() {
  550. this.$refs['temp'].validate(valid => {
  551. if (valid) {
  552. // 卡余额
  553. this.temp.cardAmount = parseFloat(this.temp.cardAmount).toFixed(2)
  554. console.log(this.requestParam, '000')
  555. this.requestParam = {}
  556. this.requestParam.common = { 'returnmap': '0' }
  557. this.requestParam.data = []
  558. if (this.temp.departmentId == undefined || this.temp.departmentId == '') {
  559. this.temp.departmentId = ''
  560. this.temp.departmentName = ''
  561. }
  562. if (this.temp.assetId == undefined || this.temp.assetId == '') {
  563. this.temp.assetId = ''
  564. this.temp.assetSum = ''
  565. }
  566. if (this.temp.pastureName == undefined || this.temp.pastureName == '') {
  567. this.temp.pastureName = Cookies.get('pasturename')
  568. }
  569. this.requestParam.data[0] = { 'name': 'checkOilcard', 'type': 'v', 'parammaps': {
  570. cardCode: this.temp.cardNumber,
  571. eqId: this.temp.assetId
  572. }}
  573. this.requestParam.data[1] = { 'name': 'insertOilcard', 'type': 'e', 'parammaps': {
  574. assetId: this.temp.assetId,
  575. assetName: this.temp.assetSum,
  576. cardAmount: this.temp.cardAmount,
  577. cardNumber: this.temp.cardNumber,
  578. cardType: this.temp.cardType,
  579. dateFormat: this.temp.dateFormat,
  580. departmentId: this.temp.departmentId,
  581. deptName: this.temp.departmentName,
  582. inputDatetime: this.temp.inputDatetime,
  583. pastureId: this.temp.pastureId,
  584. pastureName: this.temp.pastureName,
  585. rechargeNum: this.temp.rechargeNum
  586. }}
  587. if (this.temp.assetSum !== null && this.temp.assetSum !== undefined && this.temp.assetSum !== '') {
  588. this.requestParam.data[2] = { 'name': 'insertSpotList', 'resultmaps': { 'list': [{ changeType: '新增', beforeMaintenance: 0, afterMaintenance: this.temp.assetSum, changePersonId: Cookies.get('employeid') }] }}
  589. this.requestParam.data[2].children = []
  590. this.requestParam.data[2].children[0] = { 'name': 'insertOilcardHistory', 'type': 'e', 'parammaps': {
  591. oildcardId: '@insertOilcard.LastInsertId',
  592. changeType: '@insertSpotList.changeType',
  593. beforeMaintenance: '@insertSpotList.beforeMaintenance',
  594. afterMaintenance: '@insertSpotList.afterMaintenance',
  595. changePersonId: '@insertSpotList.changePersonId'
  596. }}
  597. }
  598. ExecDataByConfig(this.requestParam).then(response => {
  599. if (response.msg === 'fail') {
  600. this.$notify({ title: '失败', message: '保存失败-' + response.data, type: 'danger', duration: 2000 })
  601. } else {
  602. this.form_reset()
  603. this.$notify({ title: '成功', message: '新增成功', type: 'success', duration: 2000 })
  604. }
  605. })
  606. }
  607. })
  608. },
  609. createRechargeData() {
  610. this.$refs['temp'].validate(valid => {
  611. if (valid) {
  612. const rechargeNum = /^\d+(\.\d{1,2})?$/
  613. // 充值金额
  614. if (!rechargeNum.test(parseFloat(this.temp.rechargeNum))) {
  615. this.$message({ type: 'error', message: '充值金额请保留两位小数', duration: 2000 })
  616. return false
  617. }
  618. this.postDataPramas.common = { 'returnmap': '0' }
  619. this.postDataPramas.data = []
  620. this.postDataPramas.data[0] = { 'name': 'insertrechargerecord', 'type': 'e', 'parammaps': {
  621. 'id': this.temp.id,
  622. 'employeId': this.temp.employeId,
  623. 'cardCode': this.temp.cardCode,
  624. 'rechargeNum': this.temp.rechargeNum
  625. }}
  626. this.postDataPramas.data[1] = { 'name': 'updateCardbalanceExecData', 'type': 'e', 'parammaps': {
  627. 'id': this.temp.id,
  628. 'rechargeNum': this.temp.rechargeNum
  629. }}
  630. ExecDataByConfig(this.postDataPramas).then(response => {
  631. if (response.msg === 'fail') {
  632. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  633. } else {
  634. this.get_table_data()
  635. this.getrechargedataListParmList()
  636. this.rechargeFFormVisible = false
  637. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  638. }
  639. })
  640. }
  641. })
  642. },
  643. createRecharge() {
  644. this.dialogStatus = 'recharge'
  645. this.rechargeFFormVisible = true
  646. this.$set(this.temp, 'employeId', parseFloat(Cookies.get('employeid')))
  647. this.$set(this.temp, 'rechargeNum', '')
  648. this.temp.id = this.$store.id
  649. this.temp.dateFormat = parseTime(new Date(), '{y}-{m}-{d}')
  650. this.temp.cardCode = this.$store.cardCode
  651. // this.$nextTick(() => {
  652. // this.$refs['temp'].clearValidate()
  653. // })
  654. },
  655. handleChange(row) {
  656. this.textMap.change = row.cardNumber + '-变更记录'
  657. this.cardNumber = row.cardNumber
  658. this.tabledialogStatus = 'change'
  659. this.changeFormVisible = true
  660. this.getchangedataListParm.parammaps['oildcardId'] = row.id
  661. this.temp.dateFormat = parseTime(new Date(), '{y}-{m}-{d}')
  662. // this.getchangedataListParmList()
  663. this.getchangedataListParmList2(row)
  664. },
  665. getchangedataListParmList2(row) {
  666. this.changelistLoading = true
  667. this.getchangedataListParm2 = {}
  668. this.getchangedataListParm2.common = { 'returnmap': '0' }
  669. this.getchangedataListParm2.data = []
  670. this.getchangedataListParm2.data[0] = { 'name': 'getOilcardstatuehistory', 'type': 'sm', 'parammaps': {
  671. id: row.id
  672. }}
  673. this.getchangedataListParm2.data[1] = { 'name': 'getOilcardHistory', 'type': 'sm', 'parammaps': {
  674. id: row.id
  675. }}
  676. ExecDataByConfig(this.getchangedataListParm2).then(response => {
  677. if (response.data[0].resultmaps !== null) {
  678. this.changelist2 = response.data[0].resultmaps
  679. } else {
  680. this.changelist2 = []
  681. }
  682. if (response.data[1].resultmaps !== null) {
  683. this.changelist = response.data[1].resultmaps
  684. } else {
  685. this.changelist = []
  686. }
  687. setTimeout(() => {
  688. this.changelistLoading = false
  689. }, 100)
  690. })
  691. // GetDataByName(this.getchangedataListParm2).then(response => {
  692. // if (response.data.list !== null) {
  693. // this.changelist2 = response.data.list
  694. // } else {
  695. // this.changelist2 = []
  696. // }
  697. // setTimeout(() => {
  698. // this.changelistLoading2 = false
  699. // }, 100)
  700. // })
  701. },
  702. handleRecharge(row) {
  703. this.rechargeTemp = Object.assign({}, row)
  704. this.tabledialogStatus = 'recharge'
  705. this.rechargeFormVisible = true
  706. this.rechargelistLoading = true
  707. this.getrechargedataListParm.parammaps['cardId'] = row.id
  708. this.$store.id = row.id
  709. this.$store.cardCode = row.cardNumber
  710. this.getrechargedataListParmList()
  711. },
  712. getrechargedataListParmList() {
  713. GetDataByName(this.getrechargedataListParm).then(response => {
  714. this.rechargelist = response.data.list
  715. setTimeout(() => {
  716. this.rechargelistLoading = false
  717. }, 100)
  718. })
  719. },
  720. form_edit(row) {
  721. this.temp = Object.assign({}, row) // copy obj
  722. this.dialogStatus = 'update'
  723. this.dialogFormVisible = true
  724. if (this.temp.assetId == '' || this.temp.assetId == undefined) {
  725. this.temp.pastureName = ''
  726. }
  727. this.$nextTick(() => {
  728. this.$refs['temp'].clearValidate()
  729. })
  730. },
  731. edit_dialog_save() {
  732. this.$refs['temp'].validate(valid => {
  733. if (valid) {
  734. // 卡余额
  735. this.temp.cardAmount = parseFloat(this.temp.cardAmount).toFixed(2)
  736. this.requestParam = {}
  737. this.requestParam.common = { 'returnmap': '0' }
  738. this.requestParam.data = []
  739. if (this.temp.pastureName == undefined || this.temp.pastureName == '') {
  740. this.temp.pastureName = Cookies.get('pasturename')
  741. }
  742. if (this.temp.assetSum == '' || this.temp.assetSum == null || this.temp.assetSum == undefined) {
  743. this.temp.pastureName = ''
  744. this.temp.deptName = ''
  745. this.temp.departmentId = ''
  746. this.temp.assetId = ''
  747. this.requestParam.data[0] = { 'name': 'insertOilcardHistory', 'type': 'e', 'parammaps': {
  748. changeType: '删除',
  749. beforeMaintenance: 1,
  750. afterMaintenance: this.temp.assetSum,
  751. changePersonId: Cookies.get('employeid'),
  752. oildcardId: this.temp.id,
  753. pastureId: this.temp.pastureId,
  754. pastureName: this.temp.pastureName
  755. }}
  756. } else {
  757. this.requestParam.data[0] = { 'name': 'insertOilcardHistory', 'type': 'e', 'parammaps': {
  758. changeType: '修改',
  759. beforeMaintenance: 1,
  760. afterMaintenance: this.temp.assetSum,
  761. changePersonId: Cookies.get('employeid'),
  762. oildcardId: this.temp.id,
  763. pastureId: this.temp.pastureId,
  764. pastureName: this.temp.pastureName
  765. }}
  766. }
  767. this.requestParam.data[1] = { 'name': 'updateOilcard', 'type': 'e', 'parammaps': {
  768. cardNumber: this.temp.cardNumber,
  769. cardType: this.temp.cardType,
  770. cardAmount: this.temp.cardAmount,
  771. assetId: this.temp.assetId,
  772. departmentId: this.temp.departmentId,
  773. id: this.temp.id,
  774. pastureId: this.temp.pastureId,
  775. pastureName: this.temp.pastureName
  776. }}
  777. ExecDataByConfig(this.requestParam).then(response => {
  778. if (response.msg === 'fail') {
  779. this.$notify({ title: '失败', message: '保存失败-' + response.data, type: 'danger', duration: 2000 })
  780. } else {
  781. this.get_table_data()
  782. this.dialogFormVisible = false
  783. this.$notify({ title: '成功', message: '修改成功', type: 'success', duration: 2000 })
  784. }
  785. })
  786. }
  787. })
  788. },
  789. handleDisable(row) {
  790. var statue = ''
  791. if (row.enable == 0) {
  792. statue = '停用'
  793. } else {
  794. statue = '启用'
  795. }
  796. var enable = ''
  797. if (row.enable == 0) {
  798. enable = '1'
  799. } else {
  800. enable = '0'
  801. }
  802. var aa = '确认' + statue + '?'
  803. MessageBox.confirm('油卡编号' + row.cardNumber, aa, { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
  804. this.requestParam = {}
  805. this.requestParam.common = { 'returnmap': '0' }
  806. this.requestParam.data = []
  807. this.requestParam.data[0] = { 'name': 'insertOilcardstatuehistory', 'type': 'e', 'parammaps': {
  808. oilCardId: row.id,
  809. statue: statue,
  810. personId: Cookies.get('employeid')
  811. }}
  812. this.requestParam.data[1] = { 'name': 'deleteOilcard', 'type': 'e', 'parammaps': {
  813. id: row.id,
  814. enable: enable
  815. }}
  816. console.log(this.requestParam)
  817. ExecDataByConfig(this.requestParam).then(response => {
  818. if (response.msg === 'fail') {
  819. this.$notify({ title: '失败', message: '失败' + response.data, type: 'danger', duration: 2000 })
  820. } else {
  821. this.get_table_data()
  822. this.dialogFormVisible = false
  823. this.$notify({ title: '成功', message: '成功', type: 'success', duration: 2000 })
  824. }
  825. })
  826. }).catch(() => {
  827. this.$message({ type: 'info', message: '已取消停用' })
  828. })
  829. },
  830. form_delete(row) {
  831. MessageBox.confirm('油卡编号' + row.cardNumber, '确认删除?', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => {
  832. this.requestParam = {}
  833. this.requestParam.name = 'checkDeleteOilcard'
  834. this.requestParam.type = 'v'
  835. this.requestParam.parammaps = {}
  836. this.requestParam.parammaps.id = row.id
  837. ExecDataByConfig(this.requestParam).then((response) => {
  838. console.log(response)
  839. if (response.data == '成功执行!') {
  840. this.requestParam2.name = 'deleteOilcard2'
  841. this.requestParam2.parammaps = {}
  842. this.requestParam2.parammaps['id'] = row.id
  843. PostDataByName(this.requestParam2).then((response) => {
  844. if (response.msg == 'fail') {
  845. this.$notify({ title: '失败', message: '失败' + response.data, type: 'danger', duration: 2000 })
  846. } else {
  847. this.get_table_data()
  848. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  849. }
  850. })
  851. } else {
  852. this.$notify({ title: '失败', message: '失败' + response.data, type: 'danger', duration: 2000 })
  853. }
  854. })
  855. }).catch(() => {
  856. this.$message({ type: 'info', message: '已取消删除' })
  857. })
  858. },
  859. handleformNameSelect(item) {
  860. console.log(item)
  861. this.temp.assetSum = item.assetName
  862. this.temp.assetId = item.assetId
  863. this.temp.departmentName = item.deptName
  864. this.temp.departmentId = item.departmentId
  865. this.temp.pastureId = item.pastureId
  866. this.temp.pastureName = item.pastureName
  867. },
  868. blurformNameSelect(item) {
  869. this.temp.assetSum = ''
  870. this.temp.assetId = ''
  871. this.temp.deptName = ''
  872. this.temp.departmentId = ''
  873. this.temp.departmentName = ''
  874. this.temp.pastureName = ''
  875. },
  876. formNumberSearch(queryString, cb) {
  877. this.requestFilterParams.name = 'findAssetM'
  878. this.requestFilterParams.parammaps['pastureId'] = Cookies.get('pastureid')
  879. this.requestFilterParams.parammaps['assetName'] = queryString
  880. GetDataByName(this.requestFilterParams).then(response => {
  881. if (response.data.list === null) {
  882. this.formNumberSearchList = []
  883. } else {
  884. this.formNumberSearchList = response.data.list
  885. }
  886. console.log(this.formNumberSearchList)
  887. console.log(this.formNumberSearchList[0])
  888. console.log('queryString', queryString)
  889. var results = queryString ? this.formNumberSearchList.filter(this.createFilter(queryString)) : this.formNumberSearchList
  890. cb(results)
  891. })
  892. },
  893. beforeImportExcel(file) {
  894. const isLt2M = file.size / 1024 / 1024 < 10
  895. if (!isLt2M) {
  896. this.$message.error('上传文件大小不能超过 10MB!')
  897. }
  898. return isLt2M
  899. },
  900. handleImportExcelSuccess(res, file) {
  901. this.get_table_data()
  902. if (res.msg === 'ok') {
  903. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  904. if (res.data.err_count > 0) {
  905. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  906. import('@/vendor/Export2Excel').then(excel => {
  907. const list1 = res.data.result
  908. const tHeader = ['牧场', '车自编号', '油卡', '类型', '上次用油量', '部门', '错误信息']
  909. const filterVal = ['牧场', '车自编号', '油卡', '类型', '上次用油量', '部门', 'error_msg']
  910. const data1 = this.formatJson(filterVal, list1)
  911. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '油卡', autoWidth: true, bookType: 'xlsx' })
  912. })
  913. }
  914. } else {
  915. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  916. }
  917. },
  918. formatJson(filterVal, jsonData) {
  919. return jsonData.map(v =>
  920. filterVal.map(j => {
  921. if (j === 'timestamp') { return parseTime(v[j]) } else { return v[j] }
  922. })
  923. )
  924. },
  925. handleDownloadTemp() {
  926. import('@/vendor/Export2Excel').then(excel => {
  927. const list1 = []
  928. const tHeader = [
  929. '牧场', '车自编号', '油卡', '类型', '余额', '部门'
  930. ]
  931. const filterVal = [
  932. '牧场', '车自编号', '油卡', '类型', '余额', '部门'
  933. ]
  934. const data1 = this.formatJson(filterVal, list1)
  935. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '油卡模板', autoWidth: true, bookType: 'xlsx' })
  936. })
  937. },
  938. handlecardNumberSelect(item) {
  939. console.log(item)
  940. this.getdataListParm.parammaps.cardNumber = item.assetName
  941. },
  942. cardNumberSearch(queryString, cb) {
  943. this.requestFilterParams2.name = 'getOilcardList'
  944. this.requestFilterParams2.parammaps['cardNumber'] = queryString
  945. GetDataByName(this.requestFilterParams2).then(response => {
  946. if (response.data.list === null) {
  947. this.cardNumberSearchList = []
  948. } else {
  949. this.cardNumberSearchList = response.data.list
  950. }
  951. var results = queryString ? this.cardNumberSearchList.filter(this.createFilter(queryString)) : this.cardNumberSearchList
  952. cb(results)
  953. })
  954. },
  955. handleDownload() {
  956. this.$alert('油卡正在导出中,请勿刷新或离开本页面,若导出时间过长,建议缩小导出数据范围重新导出', {})
  957. this.isPercentage = true
  958. this.percentage = 1
  959. var timer = setInterval(() => {
  960. this.percentage += 5
  961. if (this.percentage > 95) {
  962. this.percentage = 99
  963. clearInterval(timer)
  964. }
  965. this.percentage = this.percentage
  966. }, 1000)
  967. this.downLoadParm.name = 'getOilcardList'
  968. this.downLoadParm.parammaps = this.getdataListParm.parammaps
  969. GetDataByName(this.downLoadParm).then(response => {
  970. if(response.data.list !== null && response.data.list !== ''){
  971. for(let i=0;i<response.data.list.length;i++){
  972. if(response.data.list[i].enable == 0){
  973. this.$set(response.data.list[i],'enable','启用')
  974. }else{
  975. this.$set(response.data.list[i],'enable','停用')
  976. }
  977. }
  978. }
  979. this.downLoadList = response.data.list
  980. if (response.data.list !== '') {
  981. this.percentage = 99
  982. setTimeout(() => {
  983. this.isPercentage = false
  984. }, 2000)
  985. }
  986. console.log(this.downLoadList)
  987. const elecExcelDatas = [
  988. {
  989. tHeader: ['部门', '油卡编号', '油卡类型', '剩余余额', '设备编号', '设备名称', '油卡状态'],
  990. filterVal: ['departmentName', 'cardNumber', 'cardType', 'cardAmount', 'assetNumber', 'assetName', 'enable'],
  991. tableDatas: this.downLoadList,
  992. sheetName: '油卡'
  993. }
  994. ]
  995. json2excel(elecExcelDatas, '油卡', true, 'xlsx')
  996. })
  997. },
  998. }
  999. }
  1000. </script>