综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 11KB

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