carManage-add-or-update.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <el-dialog
  3. :title="!dataForm.id ? '车辆注册' : '修改'"
  4. :close-on-click-modal="false"
  5. :visible.sync="visible" width="80%"
  6. >
  7. <el-form :model="dataFormD" :rules="dataRule" ref="dataFormD" @keyup.enter.native="dataFormSubmit()"
  8. label-width="125px"
  9. >
  10. <el-form-item label="车队名称" prop="fleetCompanyId" style="width: 325px">
  11. <el-select
  12. v-model="dataFormD.fleetCompanyId"
  13. filterable
  14. remote
  15. reserve-keyword
  16. placeholder="请输入关键词"
  17. :remote-method="handleSelect"
  18. >
  19. <el-option
  20. v-for="item in optionsProjectTypeItem"
  21. :key="item.id"
  22. :label="item.companyName"
  23. :value="item.id"
  24. >
  25. </el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="车牌号" prop="carNum" style="width: 325px">
  29. <el-input v-model="dataFormD.carNum" style="width: 200px" placeholder="车牌号"></el-input>
  30. </el-form-item>
  31. <el-form-item label="驾驶员" prop="carNum" style="width: 325px">
  32. <el-input v-model="dataFormD.carNum" style="width: 200px" placeholder="驾驶员"></el-input>
  33. </el-form-item>
  34. <el-form-item label="挂号" prop="hangNum" style="width: 325px">
  35. <el-input v-model="dataFormD.hangNum" style="width: 200px" placeholder="挂号"></el-input>
  36. </el-form-item>
  37. <el-form-item label="燃油类型" prop="fuelType" style="width: 325px">
  38. <el-input v-model="dataFormD.fuelType" style="width: 200px" placeholder="燃油类型"></el-input>
  39. </el-form-item>
  40. <el-form-item label="车辆类型" prop="carType" style="width: 325px">
  41. <el-input v-model="dataFormD.carType" style="width: 200px" placeholder="车辆类型"></el-input>
  42. </el-form-item>
  43. <el-form-item label="车辆名称" prop="carName" style="width: 325px">
  44. <el-input v-model="dataFormD.carName" style="width: 200px" placeholder="车辆名称"></el-input>
  45. </el-form-item>
  46. <el-form-item label="车辆品牌" prop="carBrand" style="width: 325px">
  47. <el-input v-model="dataFormD.carBrand" style="width: 200px" placeholder="车辆品牌"></el-input>
  48. </el-form-item>
  49. <el-form-item label="制造单位" prop="manufactureUnit" style="width: 325px">
  50. <el-input v-model="dataFormD.manufactureUnit" style="width: 200px" placeholder="制造单位"></el-input>
  51. </el-form-item>
  52. <el-form-item label="发证机关" prop="officeOfCertificate" style="width: 325px">
  53. <el-input v-model="dataFormD.officeOfCertificate" style="width: 200px" placeholder="发证机关"></el-input>
  54. </el-form-item>
  55. <el-form-item label="牵引车辆型号" prop="pullCarType" style="width: 325px">
  56. <el-input v-model="dataFormD.pullCarType" style="width: 200px" placeholder="牵引车辆型号"></el-input>
  57. </el-form-item>
  58. <el-form-item label="牵引车车架号" prop="pullCarShelfNum" style="width: 325px">
  59. <el-input v-model="dataFormD.pullCarShelfNum" style="width: 200px" placeholder="牵引车车架号"></el-input>
  60. </el-form-item>
  61. <el-form-item label="挂车型号" prop="mountCarType" style="width: 325px">
  62. <el-input v-model="dataFormD.mountCarType" style="width: 200px" placeholder="挂车型号"></el-input>
  63. </el-form-item>
  64. <el-form-item label="挂车车架号" prop="mountCarNum" style="width: 325px">
  65. <el-input v-model="dataFormD.mountCarNum" style="width: 200px" placeholder="挂车车架号"></el-input>
  66. </el-form-item>
  67. <el-form-item label="发动机型号" prop="engine" style="width: 325px">
  68. <el-input v-model="dataFormD.engine" style="width: 200px" placeholder="发动机型号"></el-input>
  69. </el-form-item>
  70. <el-form-item label="核载人数" prop="carLoadPersion" style="width: 325px">
  71. <el-input v-model="dataFormD.carLoadPersion" style="width: 200px" placeholder="核载人数"></el-input>
  72. </el-form-item>
  73. <el-form-item label="购车日期" prop="buyCarDate" style="width: 325px">
  74. <!-- <el-input v-model="dataForm.buyCarDate" placeholder="购车日期"></el-input>-->
  75. <el-date-picker
  76. style="width: 200px"
  77. value-format="yyyy-MM-dd HH:mm:ss"
  78. v-model="dataFormD.buyCarDate"
  79. type="date"
  80. placeholder="创建时间"
  81. >
  82. </el-date-picker>
  83. </el-form-item>
  84. <el-form-item label="注册日期" prop="regiestDate" style="width: 325px">
  85. <!-- <el-input v-model="dataForm.regiestDate" placeholder="注册日期"></el-input>-->
  86. <el-date-picker
  87. style="width: 200px"
  88. value-format="yyyy-MM-dd HH:mm:ss"
  89. v-model="dataFormD.regiestDate"
  90. type="date"
  91. placeholder="创建时间"
  92. >
  93. </el-date-picker>
  94. </el-form-item>
  95. <el-form-item label="报废日期" prop="abandonDate" style="width: 325px">
  96. <!-- <el-input v-model="dataForm.abandonDate" placeholder="报废日期"></el-input>-->
  97. <el-date-picker
  98. style="width: 200px"
  99. value-format="yyyy-MM-dd HH:mm:ss"
  100. v-model="dataFormD.abandonDate"
  101. type="date"
  102. placeholder="创建时间"
  103. >
  104. </el-date-picker>
  105. </el-form-item>
  106. <el-form-item label="外阔尺寸mm" prop="outerSize" style="width: 325px">
  107. <el-input v-model="dataFormD.outerSize" style="width: 200px" placeholder="外阔尺寸mm"></el-input>
  108. </el-form-item>
  109. <el-form-item label="总重量kg" prop="sumWeight" style="width: 325px">
  110. <el-input v-model="dataFormD.sumWeight" style="width: 200px" placeholder="总重量kg"></el-input>
  111. </el-form-item>
  112. <el-form-item label="核定重量kg" prop="vouchWeight" style="width: 325px">
  113. <el-input v-model="dataFormD.vouchWeight" style="width: 200px" placeholder="核定重量kg"></el-input>
  114. </el-form-item>
  115. <el-form-item label="装备质量kg" prop="equipWeight" style="width: 325px">
  116. <el-input v-model="dataFormD.equipWeight" style="width: 200px" placeholder="装备质量kg"></el-input>
  117. </el-form-item>
  118. </el-form>
  119. <el-collapse accordion>
  120. <el-form label-width="125px">
  121. <el-collapse-item title="图片上传">
  122. <el-upload
  123. :action="uploadImgUrl"
  124. list-type="picture-card"
  125. :limit="1"
  126. :on-success="success"
  127. :on-preview="handlePictureCardPreview"
  128. :on-remove="handleRemove">
  129. <i class="el-icon-plus"></i>
  130. </el-upload>
  131. <el-dialog :visible.sync="dialogVisible">
  132. <img width="100%" :src="dialogImageUrl" alt="">
  133. </el-dialog>
  134. </el-collapse-item>
  135. </el-form>
  136. </el-collapse>
  137. <span slot="footer" class="dialog-footer">
  138. <el-button @click="visible = false">取消</el-button>
  139. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  140. </span>
  141. </el-dialog>
  142. </template>
  143. <script>
  144. import { preservation, company, lookOver } from '@/api/fleet/carManage'
  145. import { getToken } from '@/utils/auth'
  146. export default {
  147. props: {
  148. dataForm: {
  149. type: Object,
  150. require: false
  151. }
  152. },
  153. data() {
  154. return {
  155. disabled: false,
  156. imageUrl: '',
  157. dataFormD: {},
  158. visible: false,
  159. loading: false,
  160. msg: '',
  161. uploadImgUrl: process.env.VUE_APP_BASE_API + '/common/upload', // 上传的图片服务器地址
  162. headers: {
  163. Authorization: 'Bearer ' + getToken()
  164. },
  165. dataRule: {
  166. fleetCompanyId: [
  167. { required: true, message: '请输入车队id', trigger: 'blur' }
  168. ],
  169. carNum: [
  170. { required: true, message: '请输入车牌号', trigger: 'blur' }
  171. ]
  172. },
  173. optionsProjectTypeItem: [],
  174. fileList: [],
  175. dialogImageUrl: '',
  176. dialogVisible: false
  177. }
  178. },
  179. methods: {
  180. success(response, file, fileList){
  181. console.log(response, file, fileList)
  182. },
  183. handleRemove(file, fileList) {
  184. console.log(file, fileList);
  185. },
  186. handlePictureCardPreview(file) {
  187. this.dialogImageUrl = file.url;
  188. this.dialogVisible = true;
  189. },
  190. init() {
  191. this.visible = true
  192. if (this.dataForm.Id) {
  193. lookOver(this.dataForm.Id).then(data => {
  194. console.log(data)
  195. this.dataFormD = data.data
  196. })
  197. }
  198. },
  199. handleSelect(query) {
  200. company(query).then(data => {
  201. console.log(data)
  202. this.optionsProjectTypeItem = data.rows
  203. })
  204. },
  205. // 表单提交
  206. dataFormSubmit() {
  207. this.$refs['dataForm'].validate((valid) => {
  208. if (valid) {
  209. preservation(this.dataForm).then(data => {
  210. if (data && data.code === 200) {
  211. this.$message({
  212. message: '操作成功',
  213. type: 'success',
  214. duration: 1500,
  215. onClose: () => {
  216. this.visible = false
  217. this.$emit('refreshDataList')
  218. }
  219. })
  220. } else {
  221. this.$message.error(data.msg)
  222. }
  223. })
  224. }
  225. })
  226. }
  227. }
  228. }
  229. </script>
  230. <style scoped>
  231. .el-form-item {
  232. width: 49%;
  233. margin-bottom: 20px;
  234. display: inline-block;
  235. }
  236. .el-select {
  237. display: block;
  238. }
  239. .upload-demo {
  240. margin-left: 50px;
  241. }
  242. .avatar-uploader .el-upload {
  243. border: 1px dashed #d9d9d9;
  244. border-radius: 6px;
  245. cursor: pointer;
  246. position: relative;
  247. overflow: hidden;
  248. }
  249. .avatar-uploader .el-upload:hover {
  250. border-color: #409EFF;
  251. }
  252. .avatar-uploader-icon {
  253. font-size: 28px;
  254. color: #8c939d;
  255. width: 178px;
  256. height: 178px;
  257. line-height: 178px;
  258. text-align: center;
  259. }
  260. .avatar {
  261. width: 178px;
  262. height: 178px;
  263. display: block;
  264. }
  265. </style>