index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="88px">
  4. <el-form-item label="设备类型" prop="deviceType">
  5. <el-select v-model="queryParams.deviceType" clearable placeholder="请选择">
  6. <el-option
  7. v-for="dict in deviceTypeOptions"
  8. :key="dict.dictValue"
  9. :label="dict.dictLabel"
  10. :value="dict.dictValue"
  11. ></el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="设备序列号" prop="deviceSerialNum">
  15. <el-input
  16. v-model="queryParams.deviceSerialNum"
  17. placeholder="请输入设备序列号"
  18. clearable
  19. size="small"
  20. @keyup.enter.native="handleQuery"
  21. />
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  25. <el-button type="info" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  26. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
  27. </el-form-item>
  28. </el-form>
  29. <el-table v-loading="loading" :data="manageList" @selection-change="handleSelectionChange">
  30. <el-table-column label="主键自增id" v-if="false" align="center" prop="deviceId" />
  31. <el-table-column label="油站名称" align="center" prop="stationName" />
  32. <el-table-column label="设备序列号" align="center" prop="deviceSerialNum" />
  33. <el-table-column label="设备厂家" align="center" prop="deviceFactory" />
  34. <el-table-column label="油站名称id" v-if="false" align="center" prop="stationId" />
  35. <el-table-column label="绑定油枪号" align="center" prop="gunNo" />
  36. <el-table-column label="设备状态" align="center">
  37. <template slot-scope="scope">
  38. <el-switch
  39. v-model="scope.row.deviceStatus"
  40. active-value="1"
  41. inactive-value="2"
  42. @change="handleStatusUpdate(scope.row)"
  43. ></el-switch>
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  47. <template slot-scope="scope">
  48. <el-button
  49. size="mini"
  50. type="text"
  51. icon="el-icon-edit"
  52. @click="handleUpdate(scope.row)"
  53. v-hasPermi="['station:manage:edit']"
  54. >修改</el-button>
  55. <el-button
  56. size="mini"
  57. type="text"
  58. icon="el-icon-delete"
  59. @click="handleDelete(scope.row)"
  60. v-hasPermi="['station:manage:remove']"
  61. >删除</el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <pagination
  66. v-show="total>0"
  67. :total="total"
  68. :page.sync="queryParams.pageNum"
  69. :limit.sync="queryParams.pageSize"
  70. @pagination="getList"
  71. />
  72. <!-- 添加或修改油站设备管理对话框 -->
  73. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  74. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  75. <el-form-item label="设备编号" prop="deviceNo">
  76. <el-input v-model="form.deviceNo" placeholder="请输入设备编号" />
  77. </el-form-item>
  78. <el-form-item label="设备名称" prop="deviceName">
  79. <el-input v-model="form.deviceName" placeholder="请输入设备名称" />
  80. </el-form-item>
  81. <el-form-item label="设备序列号" prop="deviceSerialNum">
  82. <el-input v-model="form.deviceSerialNum" placeholder="请输入设备序列号" />
  83. </el-form-item>
  84. <el-form-item label="设备类型" >
  85. <el-select v-model="form.deviceType" placeholder="请选择" clearable size="small">
  86. <el-option
  87. v-for="dict in deviceTypeOptions"
  88. :key="dict.dictValue"
  89. :label="dict.dictLabel"
  90. :value="dict.dictValue"
  91. ></el-option>
  92. </el-select>
  93. </el-form-item>
  94. <el-form-item label="绑定油枪号" prop="gunNo">
  95. <el-checkbox-group v-model="gunNoList">
  96. <el-checkbox
  97. v-for = "item in checkList"
  98. :key="item.oilGunId"
  99. :label="item.oilGunNo"
  100. :value="item.oilGunNo"
  101. >
  102. {{item.oilGunNo+"号枪/"+item.oilName}}
  103. </el-checkbox>
  104. </el-checkbox-group>
  105. </el-form-item>
  106. <el-form-item label="设备状态" >
  107. <el-select v-model="form.deviceStatus" clearable size="small" placeholder="请选择">
  108. <el-option
  109. v-for="dict in deviceStatusOptions"
  110. :key="dict.dictValue"
  111. :label="dict.dictLabel"
  112. :value="dict.dictValue"
  113. ></el-option>
  114. </el-select>
  115. </el-form-item>
  116. <el-form-item label="设备厂家" prop="deviceFactory">
  117. <el-input v-model="form.deviceFactory" placeholder="请输入设备厂家" />
  118. </el-form-item>
  119. </el-form>
  120. <div slot="footer" class="dialog-footer">
  121. <el-button type="primary" @click="submitForm">确 定</el-button>
  122. <el-button @click="cancel">取 消</el-button>
  123. </div>
  124. </el-dialog>
  125. </div>
  126. </template>
  127. <script>
  128. import { listManage, getManage, delManage, addManage, updateManage, exportManage,changeManageStatus } from "@/api/station/manage";
  129. import{listGun} from "@/api/station/gun";
  130. import { getDept } from "@/api/system/dept";
  131. export default {
  132. name: "Manage",
  133. data() {
  134. return {
  135. // 遮罩层
  136. loading: true,
  137. // 选中数组
  138. ids: [],
  139. // 非单个禁用
  140. single: true,
  141. // 非多个禁用
  142. multiple: true,
  143. // 显示搜索条件
  144. showSearch: true,
  145. // 总条数
  146. total: 0,
  147. // 油站设备管理表格数据
  148. manageList: [],
  149. //油枪复选
  150. checkList: [],
  151. gunNoList:[],
  152. //设备状态
  153. deviceStatusOptions:[],
  154. //设备类型
  155. deviceTypeOptions:[],
  156. stationOptions:[],
  157. // 弹出层标题
  158. title: "",
  159. // 是否显示弹出层
  160. open: false,
  161. // 查询参数
  162. queryParams: {
  163. pageNum: 1,
  164. pageSize: 10,
  165. deviceNo: null,
  166. deviceName: null,
  167. stationId: null,
  168. stationName: null,
  169. deviceType: null,
  170. deviceSerialNum: null,
  171. gunNo: null,
  172. deviceStatus: null,
  173. deviceFactory: null
  174. },
  175. deptId:null,
  176. queryInfo:{
  177. stationId:null
  178. },
  179. // 查询参数
  180. deptInfo: {},
  181. query:{
  182. deptId:null
  183. },
  184. // 表单参数
  185. form: {},
  186. // 表单校验
  187. rules: {
  188. }
  189. };
  190. },
  191. created() {
  192. this.getList();
  193. //字典设备状态
  194. this.getDicts("device_status").then(response => {
  195. this.deviceStatusOptions = response.data;
  196. });
  197. //字典设备类型
  198. this.getDicts("device_type").then(response => {
  199. this.deviceTypeOptions = response.data;
  200. });
  201. },
  202. methods: {
  203. /** 查询油站设备管理列表 */
  204. getList() {
  205. this.loading = true;
  206. this.queryParams.stationId = this.$store.selectDeptId;
  207. if(this.queryParams.stationId==null || this.queryParams.stationId==""){
  208. this.queryParams.stationId =this.$store.state.user.deptId;
  209. }
  210. listManage(this.queryParams).then(response => {
  211. this.manageList = response.rows;
  212. this.total = response.total;
  213. this.loading = false;
  214. });
  215. },
  216. // 取消按钮
  217. cancel() {
  218. this.open = false;
  219. this.reset();
  220. },
  221. // 表单重置
  222. reset() {
  223. this.form = {
  224. deviceId: null,
  225. deviceNo: null,
  226. deviceName: null,
  227. stationId: null,
  228. stationName: null,
  229. deviceType: null,
  230. deviceSerialNum: null,
  231. gunNo: null,
  232. deviceStatus: null,
  233. deviceFactory: null
  234. };
  235. this.resetForm("form");
  236. this.gunNoList.length=0;
  237. },
  238. deviceStatusFotmat(row, column){
  239. if(row.deviceStatus === '1'){
  240. return '在用'
  241. }else if(row.deviceStatus === '2'){
  242. return '停用'
  243. }
  244. },
  245. /** 搜索按钮操作 */
  246. handleQuery() {
  247. this.queryParams.pageNum = 1;
  248. this.getList();
  249. },
  250. /** 重置按钮操作 */
  251. resetQuery() {
  252. this.resetForm("queryForm");
  253. this.handleQuery();
  254. },
  255. // 多选框选中数据
  256. handleSelectionChange(selection) {
  257. this.ids = selection.map(item => item.deviceId)
  258. this.single = selection.length!==1
  259. this.multiple = !selection.length
  260. },
  261. /** 新增按钮操作 */
  262. handleAdd() {
  263. this.reset();
  264. this.deptId=this.$store.selectDeptId;
  265. if(this.deptId==null || this.deptId==""){
  266. this.deptId =this.$store.state.user.deptId;
  267. }
  268. getDept(this.deptId).then(response => {
  269. this.deptInfo = response.data;
  270. if(this.deptInfo.jiBie==2){
  271. this.open = true;
  272. this.title = "添加油站设备管理";
  273. this.form.stationId=this.deptInfo.deptId;
  274. this.form.stationName=this.deptInfo.deptName;
  275. this.queryInfo.stationId=this.deptInfo.deptId;
  276. listGun(this.queryInfo).then(response => {
  277. this.checkList = response.rows;
  278. });
  279. }else{
  280. this.msgSuccess("请选择油站");
  281. }
  282. });
  283. },
  284. /** 修改按钮操作 */
  285. handleUpdate(row) {
  286. this.reset();
  287. const deviceId = row.deviceId || this.ids
  288. getManage(deviceId).then(response => {
  289. this.form = response.data;
  290. if(this.form.gunNo!=null &&this.form.gunNo!="" ){
  291. this.gunNoList=this.form.gunNo.split(",");
  292. }
  293. this.queryInfo.stationId=this.form.stationId;
  294. listGun(this.queryInfo).then(response => {
  295. this.checkList = response.rows;
  296. });
  297. this.open = true;
  298. this.title = "修改油站设备管理";
  299. });
  300. },
  301. handleStatusUpdate(row){
  302. let text = row.deviceStatus === "1" ? "启用" : "停用";
  303. this.$confirm('确认要"' + text + '""' + row.deviceSerialNum + '"设备吗?', "警告", {
  304. confirmButtonText: "确定",
  305. cancelButtonText: "取消",
  306. type: "warning"
  307. }).then(function() {
  308. return changeManageStatus(row.deviceId, row.deviceStatus);
  309. }).then(() => {
  310. this.msgSuccess(text + "成功");
  311. this.handleQuery();
  312. });
  313. },
  314. /** 提交按钮 */
  315. submitForm() {
  316. this.$refs["form"].validate(valid => {
  317. if (valid) {
  318. if(this.gunNoList !=null && this.gunNoList.length>0){
  319. this.form.gunNo=this.gunNoList.toString();
  320. }
  321. if (this.form.deviceId != null) {
  322. updateManage(this.form).then(response => {
  323. this.msgSuccess("修改成功");
  324. this.open = false;
  325. this.getList();
  326. });
  327. } else {
  328. addManage(this.form).then(response => {
  329. this.msgSuccess("新增成功");
  330. this.open = false;
  331. this.getList();
  332. });
  333. }
  334. }
  335. });
  336. },
  337. /** 删除按钮操作 */
  338. handleDelete(row) {
  339. const deviceIds = row.deviceId || this.ids;
  340. this.$confirm('是否确认删除油站设备管理', "警告", {
  341. confirmButtonText: "确定",
  342. cancelButtonText: "取消",
  343. type: "warning"
  344. }).then(function() {
  345. return delManage(deviceIds);
  346. }).then(() => {
  347. this.getList();
  348. this.msgSuccess("删除成功");
  349. })
  350. },
  351. onInstitutionChang(e){
  352. let obj = {};
  353. obj = this.stationOptions.find((item)=>{//这里的userList就是上面遍历的数据源
  354. return item.deptId === e;//筛选出匹配数据
  355. })
  356. this.form.stationName=obj.deptName;
  357. this.queryInfo.stationId=obj.deptId;
  358. listGun(this.queryInfo).then(response => {
  359. this.checkList = response.rows;
  360. });
  361. },
  362. /** 导出按钮操作 */
  363. handleExport() {
  364. const queryParams = this.queryParams;
  365. this.$confirm('是否确认导出所有油站设备管理数据项?', "警告", {
  366. confirmButtonText: "确定",
  367. cancelButtonText: "取消",
  368. type: "warning"
  369. }).then(function() {
  370. return exportManage(queryParams);
  371. }).then(response => {
  372. this.download(response.msg);
  373. })
  374. }
  375. }
  376. };
  377. </script>