综合办公系统
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

index.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="车牌号" prop="licensePlate">
  5. <el-input v-model="queryParams.licensePlate" placeholder="请输入车牌号" clearable @keyup.enter.native="handleQuery" />
  6. </el-form-item>
  7. <!-- <el-form-item label="驾驶员" prop="driver">
  8. <el-input v-model="queryParams.driver" placeholder="请输入驾驶员" clearable @keyup.enter.native="handleQuery" />
  9. </el-form-item> -->
  10. <el-form-item>
  11. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  12. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  13. </el-form-item>
  14. </el-form>
  15. <el-row :gutter="10" class="mb8">
  16. <el-col :span="1.5">
  17. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  18. v-hasPermi="['oa:car:add']">新增</el-button>
  19. </el-col>
  20. <el-col :span="1.5">
  21. <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
  22. v-hasPermi="['oa:car:edit']">修改</el-button>
  23. </el-col>
  24. <el-col :span="1.5">
  25. <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
  26. v-hasPermi="['oa:car:remove']">删除</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
  30. v-hasPermi="['oa:car:export']">导出</el-button>
  31. </el-col>
  32. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  33. </el-row>
  34. <el-table v-loading="loading" :data="carList" @selection-change="handleSelectionChange">
  35. <el-table-column type="selection" width="55" align="center" />
  36. <!-- <el-table-column label="车辆id" align="center" prop="carId" /> -->
  37. <el-table-column label="车辆状态" align="center" prop="status">
  38. <template slot-scope="scope">
  39. <el-tag :type="statusTypeStyle(scope.row.status)">{{ statusTypeText(scope.row.status) }}</el-tag>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="车牌号" align="center" prop="licensePlate" />
  43. <el-table-column label="驾驶员" align="center" prop="driverUser.nickName" />
  44. <el-table-column label="品牌" align="center" prop="brand" />
  45. <el-table-column label="车型" align="center" prop="series" />
  46. <el-table-column label="购置时间" align="center" prop="acquisitionTime" />
  47. <el-table-column label="是否为租车" align="center" prop="isRent">
  48. <template slot-scope="scope">
  49. {{ scope.row.isRent == "0" ? "否" : "是" }}
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="购买价格" align="center" prop="cost">
  53. <template slot-scope="scope">
  54. {{ scope.row.cost + '元' }}
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="预计使用年限" align="center" prop="expectLife">
  58. <template slot-scope="scope">
  59. {{ scope.row.expectLife + '年' }}
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="预计行驶里程" align="center" prop="expectKm">
  63. <template slot-scope="scope">
  64. {{ scope.row.expectKm + '万千米' }}
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="单日成本" align="center" prop="dayCost" >
  68. <template slot-scope="scope">
  69. {{ scope.row.dayCost + '元' }}
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="备注" align="center" prop="remark" />
  73. <el-table-column label="操作" align="center" width="200px">
  74. <template slot-scope="scope">
  75. <el-button size="mini" type="text" icon="el-icon-view" @click="handleAddDetail(scope.row)"
  76. v-hasPermi="['oa:car:query']">查看明细</el-button>
  77. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  78. v-hasPermi="['oa:car:edit']">修改</el-button>
  79. <el-button size="mini" type="text" icon="el-icon-delete" style="color: #fc0000;"
  80. @click="handleDelete(scope.row)" v-hasPermi="['oa:car:remove']">删除</el-button>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <!-- <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  85. @pagination="getList" /> -->
  86. <!-- 添加或修改cmc车辆信息对话框 -->
  87. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  88. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  89. <el-form-item label="车牌号" prop="licensePlate">
  90. <el-input v-model="form.licensePlate" placeholder="请输入车牌号" />
  91. </el-form-item>
  92. <el-form-item label="品牌" prop="brand">
  93. <el-input v-model="form.brand" placeholder="请输入品牌" />
  94. </el-form-item>
  95. <el-form-item label="车型" prop="series">
  96. <el-input v-model="form.series" placeholder="请输入车型" />
  97. </el-form-item>
  98. <el-form-item label="购置时间" prop="acquisitionTime">
  99. <el-date-picker v-model="form.acquisitionTime" type="date" placeholder="选择日期" format="yyyy-MM-dd"
  100. value-format="yyyy-MM-dd">
  101. </el-date-picker>
  102. </el-form-item>
  103. <el-form-item label="购买价格" prop="cost">
  104. <el-input style="width:130px;margin-right:10px;" v-model="form.cost" placeholder="请输入金额" />
  105. <span>元</span>
  106. </el-form-item>
  107. <el-form-item label="预计使用年限" prop="expectLife">
  108. <el-input v-model="form.expectLife" placeholder="请输入年限" style="width:130px;margin-right:10px;" />
  109. <span>年</span>
  110. </el-form-item>
  111. <el-form-item label="预计行驶里程" prop="expectKm">
  112. <el-input v-model="form.expectKm" placeholder="请输入里程" style="width:130px;margin-right:10px;" />
  113. <span>万千米</span>
  114. </el-form-item>
  115. <el-form-item label="驾驶员" prop="driver">
  116. <el-select v-model="form.driver" filterable placeholder="请选择" clearable>
  117. <el-option v-for="item in driverList" :key="item.userId" :label="item.nickName" :value="item.userId">
  118. </el-option>
  119. </el-select>
  120. </el-form-item>
  121. <el-form-item label="是否为租车" prop="isRent">
  122. <el-radio-group v-model="form.isRent">
  123. <el-radio label="0">否</el-radio>
  124. <el-radio label="1">是</el-radio>
  125. </el-radio-group>
  126. </el-form-item>
  127. <el-form-item v-if="form.isRent == '1'" label="单日成本" prop="dayCost">
  128. <el-input style="width:400px;margin-right:10px;" v-model="form.dayCost" placeholder="若不填写,将以残值5%,采用年数总和法计提单日成本"/>
  129. <span>元</span>
  130. </el-form-item>
  131. </el-form>
  132. <div slot="footer" class="dialog-footer">
  133. <el-button type="primary" @click="submitForm">确 定</el-button>
  134. <el-button @click="cancel">取 消</el-button>
  135. </div>
  136. </el-dialog>
  137. </div>
  138. </template>
  139. <script>
  140. import { listCar, getCar, delCar, addCar, updateCar } from "@/api/oa/car/car";
  141. import { getUserByPost } from "@/api/system/post";
  142. export default {
  143. name: "Car",
  144. data() {
  145. return {
  146. // 遮罩层
  147. loading: true,
  148. // 选中数组
  149. ids: [],
  150. // 非单个禁用
  151. single: true,
  152. // 非多个禁用
  153. multiple: true,
  154. // 显示搜索条件
  155. showSearch: true,
  156. // 总条数
  157. total: 0,
  158. // cmc车辆信息表格数据
  159. carList: [],
  160. // 弹出层标题
  161. title: "",
  162. // 是否显示弹出层
  163. open: false,
  164. // 查询参数
  165. queryParams: {
  166. pageNum: 1,
  167. pageSize: 20,
  168. licensePlate: null,
  169. driver: null
  170. },
  171. // 表单参数
  172. form: {},
  173. // 表单校验
  174. rules: {
  175. },
  176. driverList: [],
  177. detailOpen: false
  178. };
  179. },
  180. created() {
  181. this.getList();
  182. this.getDriverList();
  183. },
  184. methods: {
  185. /** 查询cmc车辆信息列表 */
  186. getList() {
  187. this.loading = true;
  188. listCar(this.queryParams).then(response => {
  189. this.carList = response.rows;
  190. this.total = response.total;
  191. this.loading = false;
  192. });
  193. },
  194. // 查询驾驶员列表
  195. getDriverList() {
  196. getUserByPost({ postName: '驾驶员' }).then(response => {
  197. this.driverList = response.data;
  198. })
  199. },
  200. // 取消按钮
  201. cancel() {
  202. this.open = false;
  203. this.reset();
  204. },
  205. // 表单重置
  206. reset() {
  207. this.form = {
  208. carId: null,
  209. licensePlate: null,
  210. driver: null
  211. };
  212. this.resetForm("form");
  213. },
  214. /** 搜索按钮操作 */
  215. handleQuery() {
  216. this.queryParams.pageNum = 1;
  217. this.getList();
  218. },
  219. /** 重置按钮操作 */
  220. resetQuery() {
  221. this.resetForm("queryForm");
  222. this.handleQuery();
  223. },
  224. // 多选框选中数据
  225. handleSelectionChange(selection) {
  226. this.ids = selection.map(item => item.carId)
  227. this.single = selection.length !== 1
  228. this.multiple = !selection.length
  229. },
  230. /** 新增按钮操作 */
  231. handleAdd() {
  232. this.reset();
  233. this.open = true;
  234. this.title = "添加车辆信息";
  235. },
  236. /** 修改按钮操作 */
  237. handleUpdate(row) {
  238. this.reset();
  239. const carId = row.carId || this.ids
  240. getCar(carId).then(response => {
  241. this.form = response.data;
  242. this.open = true;
  243. this.title = "修改车辆信息";
  244. });
  245. },
  246. // 新增明细按钮
  247. handleAddDetail(row) {
  248. this.$router.push({
  249. path: '/car/detail',
  250. query: {
  251. carId: row.carId,
  252. }
  253. })
  254. },
  255. /** 提交按钮 */
  256. submitForm() {
  257. this.$refs["form"].validate(valid => {
  258. if (valid) {
  259. if (this.form.carId != null) {
  260. updateCar(this.form).then(response => {
  261. this.$modal.msgSuccess("修改成功");
  262. this.open = false;
  263. this.getList();
  264. });
  265. } else {
  266. addCar(this.form).then(response => {
  267. this.$modal.msgSuccess("新增成功");
  268. this.open = false;
  269. this.getList();
  270. });
  271. }
  272. }
  273. });
  274. },
  275. /** 删除按钮操作 */
  276. handleDelete(row) {
  277. const carIds = row.carId || this.ids;
  278. const licensePlate = row.licensePlate
  279. this.$modal.confirm('是否确认删除车牌号为【"' + licensePlate + '"】的车辆数据?').then(function () {
  280. return delCar(carIds);
  281. }).then(() => {
  282. this.getList();
  283. this.$modal.msgSuccess("删除成功");
  284. }).catch(() => { });
  285. },
  286. /** 导出按钮操作 */
  287. handleExport() {
  288. this.download('oa/car/export', {
  289. ...this.queryParams
  290. }, `car_${new Date().getTime()}.xlsx`)
  291. },
  292. statusTypeText(row) {
  293. if (row == '0') {
  294. return '被领用'
  295. }
  296. if (row == '1') {
  297. return '可领用'
  298. }
  299. if (row == '2') {
  300. return '维修中'
  301. }
  302. if (row == '3') {
  303. return '已停用'
  304. }
  305. if (row == '4') {
  306. return '已报废'
  307. }
  308. },
  309. statusTypeStyle(row) {
  310. if (row == '0') {
  311. return 'warning'
  312. }
  313. if (row == '1') {
  314. return 'success'
  315. }
  316. if (row == '2') {
  317. return 'danger'
  318. }
  319. if (row == '3') {
  320. return 'primary'
  321. }
  322. if (row == '4') {
  323. return 'info'
  324. }
  325. }
  326. }
  327. };
  328. </script>