index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <div style="padding: 10px">
  3. <!-- 搜索栏 -->
  4. <div style="margin-bottom: 10px">
  5. <el-select
  6. v-model="selectedDeviceId"
  7. placeholder="选择设备"
  8. size="small"
  9. style="width: 150px"
  10. clearable
  11. >
  12. <el-option
  13. style="color: black"
  14. v-for="device in devices"
  15. :key="device.id"
  16. :label="device.name"
  17. :value="device.id"
  18. />
  19. </el-select>
  20. <el-button
  21. type="primary"
  22. @click="searchCarInfo()"
  23. style="margin-left: 10px"
  24. >查询</el-button
  25. >
  26. <el-button type="primary" @click="addCarInfo()" style="margin-left: 10px"
  27. >新增</el-button
  28. ><el-button
  29. :disabled="multipleSelection.length <= 0"
  30. type="danger"
  31. @click="batchDeleteCarInfo()"
  32. style="margin-left: 10px"
  33. >批量删除</el-button
  34. >
  35. </div>
  36. <el-table
  37. v-loading="loading"
  38. :data="tableData"
  39. style="width: 100%; margin-top: 10px"
  40. border
  41. :header-cell-style="changeHeaderCellStyle"
  42. @selection-change="handleSelectionChange"
  43. >
  44. <el-table-column type="selection" width="50" align="center" />
  45. <!-- <el-table-column prop="employeeNo" label="序号" width="100" align="center" />-->
  46. <el-table-column prop="plateNumber" label="车牌号码" min-width="120" />
  47. <!-- <el-table-column prop="cardNo" label="卡号" min-width="100"/>-->
  48. <!-- <el-table-column prop="cardType" label="卡片类型" min-width="100"/>-->
  49. <!-- <el-table-column prop="cardFee" label="工本费(元)" min-width="100"/>-->
  50. <!-- <el-table-column prop="balance" label="余额(元)" min-width="100"/>-->
  51. <!-- <el-table-column prop="startTime" label="开始时间" min-width="160"/>-->
  52. <!-- <el-table-column prop="endTime" label="截止时间" min-width="160"/>-->
  53. <!-- <el-table-column prop="registerTime" label="注册时间" min-width="160"/>-->
  54. <!-- <el-table-column prop="department" label="发卡部门" min-width="120"/>-->
  55. <!-- <el-table-column prop="cardStatus" label="卡片状态" min-width="100"/>-->
  56. <!-- <el-table-column prop="issuer" label="发卡人员" min-width="120"/>-->
  57. <el-table-column prop="parkingType" label="停车类型" min-width="100" />
  58. <el-table-column prop="plateColor" label="车牌颜色" min-width="100" />
  59. <el-table-column prop="vehicleType" label="车辆类型" min-width="100" />
  60. <el-table-column prop="plateType" label="车牌类型" min-width="100" />
  61. <el-table-column prop="vehicleColor" label="车辆颜色" min-width="100" />
  62. <el-table-column prop="vehicleBrand" label="车辆品牌" min-width="100" />
  63. <el-table-column prop="ownerName" label="车主姓名" min-width="120" />
  64. <el-table-column prop="phoneNumber" label="手机号码" min-width="120" />
  65. <el-table-column prop="certificateNo" label="证件号码" min-width="120" />
  66. <!-- <el-table-column prop="address" label="住址" min-width="200"/>-->
  67. <!-- <el-table-column prop="position" label="职位" min-width="120"/>-->
  68. <!-- <el-table-column prop="company" label="所属公司" min-width="150"/>-->
  69. <!-- <el-table-column prop="departmentName" label="所在部门" min-width="150"/>-->
  70. <!-- <el-table-column prop="cardIssuerType" label="发卡器类型" min-width="120"/>-->
  71. <!-- <el-table-column prop="groupName" label="分组名称" min-width="120"/>-->
  72. <!-- <el-table-column prop="parkingPermission" label="场库权限" min-width="120"/>-->
  73. <!-- <el-table-column prop="parkingLotName" label="场库名称" min-width="120"/>-->
  74. <!-- <el-table-column prop="vehicleGroup" label="车辆群组" min-width="120"/>-->
  75. <el-table-column
  76. prop="dailyTimeRange"
  77. label="每日有效时段"
  78. min-width="120"
  79. />
  80. <el-table-column
  81. prop="historicalValidity"
  82. label="历史有效期"
  83. min-width="120"
  84. />
  85. <el-table-column prop="remarks" label="备注" min-width="200" />
  86. <!-- <el-table-column prop="dataVersion" label="数据版本" min-width="100"/>-->
  87. <!-- <el-table-column prop="packageInfo" label="包时信息" min-width="120"/>-->
  88. <!-- <el-table-column prop="engineNo" label="发动机号" min-width="120"/>-->
  89. <!-- <el-table-column prop="emissionNo" label="排放量号" min-width="120"/>-->
  90. <!-- <el-table-column prop="recognitionCode" label="识别代码" min-width="120"/>-->
  91. <!-- <el-table-column prop="vin" label="车架号" min-width="150"/>-->
  92. <!-- <el-table-column prop="displacement" label="车辆排量" min-width="120"/>-->
  93. <!-- <el-table-column prop="fleetName" label="车队名称" min-width="150"/>-->
  94. <el-table-column label="操作" fixed="right" width="160" align="center">
  95. <template slot-scope="scope">
  96. <el-button type="text" size="small" @click="viewCarInfo(scope.row)"
  97. >查看</el-button
  98. >
  99. <el-button type="text" size="small" @click="updateCarInfo(scope.row)"
  100. >修改</el-button
  101. >
  102. <el-button type="text" size="small" @click="deleteCarInfo(scope.row)"
  103. >删除</el-button
  104. >
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <car-search-dialog
  109. :visible.sync="searchVisible"
  110. :detail="currentCar"
  111. /><!-- 查看详情弹窗 -->
  112. <!-- 查看详情弹窗 -->
  113. <car-detail-dialog :visible.sync="viewVisible" :detail="currentCar" />
  114. <car-edit-dialog
  115. :visible.sync="editVisible"
  116. :userData="currentCar"
  117. :deviceId="selectedDeviceId"
  118. @success="searchCarInfo"
  119. />
  120. </div>
  121. </template>
  122. <script>
  123. import request from "@/utils/request";
  124. import CarSearchDialog from "./CarSearchDialog.vue";
  125. import CarDetailDialog from "./CarDetailDialog.vue";
  126. import CarEditDialog from "./CarEditDialog.vue";
  127. export default {
  128. name: "carManage",
  129. components: {
  130. CarSearchDialog,
  131. CarDetailDialog,
  132. CarEditDialog,
  133. },
  134. data() {
  135. return {
  136. devices: [], // 设备列表
  137. selectedDeviceId: null, // 当前选择的设备
  138. searchVisible: false,
  139. viewVisible: false,
  140. editVisible: false,
  141. tableData: [],
  142. total: 0,
  143. currentPage: 1,
  144. pageSize: 10,
  145. multipleSelection: [], // 存储选中的多行数据
  146. currentCar: null,
  147. loading: false,
  148. dialogVisible: false,
  149. dialogTitle: "新增车辆",
  150. form: {
  151. plate_number: "",
  152. owner_name: "",
  153. vehicle_type: "",
  154. },
  155. editId: null,
  156. };
  157. },
  158. mounted() {
  159. this.getDeviceNameInfo();
  160. },
  161. methods: {
  162. searchCarInfo() {
  163. console.log("查询");
  164. this.currentCar = {}; // 空对象代替 null
  165. // this.currentUser = {}; // 空对象代替 null
  166. // this.currentUser = null; // 空对象代替 null
  167. this.searchVisible = true;
  168. },
  169. viewCarInfo(row) {
  170. this.currentCar = row;
  171. this.viewVisible = true;
  172. },
  173. addCarInfo() {
  174. console.log("新增");
  175. this.currentCar = {}; // 空对象代替 null
  176. // this.currentUser = {}; // 空对象代替 null
  177. // this.currentUser = null; // 空对象代替 null
  178. this.editVisible = true;
  179. },
  180. updateCarInfo(row) {
  181. console.log("修改", row);
  182. this.currentCar = row;
  183. this.editVisible = true;
  184. },
  185. // 表格样式修改
  186. changeHeaderCellStyle(row, column, rowIndex, columnIndex) {
  187. if (row.columnIndex === 0) {
  188. return "background: #004279 ; color:#fff;"; // 修改的样式
  189. } else {
  190. return "background: #004279 ;color:#fff; ";
  191. }
  192. },
  193. // 监听多选变化
  194. handleSelectionChange(val) {
  195. this.multipleSelection = val;
  196. },
  197. // 切换页码
  198. handlePageChange(page) {
  199. this.currentPage = page;
  200. // this.searchCarInfo()
  201. },
  202. // 修改每页条数
  203. handleSizeChange(size) {
  204. this.pageSize = size;
  205. this.currentPage = 1; // 切换条数后回到第一页
  206. // this.searchCarInfo()
  207. },
  208. async getDeviceNameInfo() {
  209. try {
  210. this.loading = true;
  211. const res = await request({
  212. url: "/device/listDeviceName",
  213. method: "GET",
  214. });
  215. // 判断返回结构
  216. if (res && res.list) {
  217. this.devices = res.list;
  218. this.total = res.total || 0;
  219. console.log("设备列表:", this.devices);
  220. if (this.devices.length > 0) {
  221. this.selectedDeviceId = this.devices[0].id;
  222. console.log("选中的设备ID:", this.selectedDeviceId);
  223. // 获取该设备的人员信息
  224. // this.searchUserInfo()
  225. }
  226. } else {
  227. this.devices = [];
  228. this.total = 0;
  229. this.$message.warning("未获取到设备数据");
  230. }
  231. } catch (error) {
  232. console.error("获取设备信息失败:", error);
  233. this.$message.error("获取设备列表失败,请检查网络或后端接口!");
  234. } finally {
  235. this.loading = false;
  236. }
  237. },
  238. },
  239. };
  240. </script>