carManage-add-or-update.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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="#"
  124. list-type="picture-card"
  125. :auto-upload="false">
  126. <i slot="default" class="el-icon-plus"></i>
  127. <div slot="file" slot-scope="{file}">
  128. <img
  129. class="el-upload-list__item-thumbnail"
  130. :src="file.url" alt=""
  131. >
  132. <span class="el-upload-list__item-actions">
  133. <span
  134. class="el-upload-list__item-preview"
  135. @click="handlePictureCardPreview(file)"
  136. >
  137. <i class="el-icon-zoom-in"></i>
  138. </span>
  139. <span
  140. v-if="!disabled"
  141. class="el-upload-list__item-delete"
  142. @click="handleDownload(file)"
  143. >
  144. <i class="el-icon-download"></i>
  145. </span>
  146. <span
  147. v-if="!disabled"
  148. class="el-upload-list__item-delete"
  149. @click="handleRemove(file)"
  150. >
  151. <i class="el-icon-delete"></i>
  152. </span>
  153. </span>
  154. </div>
  155. </el-upload>
  156. <el-dialog :visible.sync="dialogVisible">
  157. <img width="100%" :src="dialogImageUrl" alt="">
  158. </el-dialog>
  159. </el-collapse-item>
  160. </el-form>
  161. </el-collapse>
  162. <span slot="footer" class="dialog-footer">
  163. <el-button @click="visible = false">取消</el-button>
  164. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  165. </span>
  166. </el-dialog>
  167. </template>
  168. <script>
  169. import { preservation, company, lookOver } from '@/api/fleet/carManage'
  170. import { getToken } from '@/utils/auth'
  171. export default {
  172. props: {
  173. dataForm: {
  174. type: Object,
  175. require: false
  176. }
  177. },
  178. data() {
  179. return {
  180. disabled: false,
  181. fTmsorderbillsattachs: [
  182. {
  183. attachName: '',
  184. attachUrl: '',
  185. actId: '1'
  186. }, {
  187. attachName: '',
  188. attachUrl: '',
  189. actId: '2'
  190. }, {
  191. attachName: '',
  192. attachUrl: '',
  193. actId: '3'
  194. }, {
  195. attachName: '',
  196. attachUrl: '',
  197. actId: '4'
  198. }, {
  199. attachName: '',
  200. attachUrl: '',
  201. actId: '5'
  202. }, {
  203. attachName: '',
  204. attachUrl: '',
  205. actId: '6'
  206. }, {
  207. attachName: '',
  208. attachUrl: '',
  209. actId: '7'
  210. }, {
  211. attachName: '',
  212. attachUrl: '',
  213. actId: '8'
  214. }, {
  215. attachName: '',
  216. attachUrl: '',
  217. actId: '9'
  218. }
  219. ],
  220. imageUrl: '',
  221. dataFormD: {},
  222. visible: false,
  223. loading: false,
  224. msg: '',
  225. uploadImgUrl: process.env.VUE_APP_BASE_API + '/common/upload', // 上传的图片服务器地址
  226. headers: {
  227. Authorization: 'Bearer ' + getToken()
  228. },
  229. dataRule: {
  230. fleetCompanyId: [
  231. { required: true, message: '请输入车队id', trigger: 'blur' }
  232. ],
  233. carNum: [
  234. { required: true, message: '请输入车牌号', trigger: 'blur' }
  235. ]
  236. },
  237. optionsProjectTypeItem: [],
  238. fileList: [],
  239. dialogImageUrl: '',
  240. dialogVisible: false
  241. }
  242. },
  243. methods: {
  244. handleRemove(file) {
  245. console.log(file);
  246. },
  247. handlePictureCardPreview(file) {
  248. this.dialogImageUrl = file.url;
  249. console.log(file)
  250. // this.dialogVisible = true;
  251. },
  252. handleDownload(file) {
  253. console.log(file);
  254. },
  255. handleAvatarSuccess(id,res,file) {
  256. console.log(id)
  257. console.log(res)
  258. console.log(file)
  259. if (res){
  260. console.log(id)
  261. // switch (id) {
  262. // case 1:
  263. // this.fTmsorderbillsattachs[0].actId = id
  264. // this.fTmsorderbillsattachs[0].attachName = res.fileName
  265. // this.fTmsorderbillsattachs[0].attachUrl = res.url
  266. // break
  267. // case 2:
  268. // this.fTmsorderbillsattachs[1].actId = id
  269. // this.fTmsorderbillsattachs[1].attachName = res.fileName
  270. // this.fTmsorderbillsattachs[1].attachUrl = res.url
  271. // break
  272. // case 3:
  273. // this.fTmsorderbillsattachs[2].actId = id
  274. // this.fTmsorderbillsattachs[2].attachName = res.fileName
  275. // this.fTmsorderbillsattachs[2].attachUrl = res.url
  276. // break
  277. // case 4:
  278. // this.fTmsorderbillsattachs[3].actId = id
  279. // this.fTmsorderbillsattachs[3].attachName = res.fileName
  280. // this.fTmsorderbillsattachs[3].attachUrl = res.url
  281. // break
  282. // case 5:
  283. // this.fTmsorderbillsattachs[4].actId = id
  284. // this.fTmsorderbillsattachs[4].attachName = res.fileName
  285. // this.fTmsorderbillsattachs[4].attachUrl = res.url
  286. // break
  287. // case 6:
  288. // this.fTmsorderbillsattachs[5].actId = id
  289. // this.fTmsorderbillsattachs[5].attachName = res.fileName
  290. // this.fTmsorderbillsattachs[5].attachUrl = res.url
  291. // break
  292. // case 7:
  293. // this.fTmsorderbillsattachs[6].actId = id
  294. // this.fTmsorderbillsattachs[6].attachName = res.fileName
  295. // this.fTmsorderbillsattachs[6].attachUrl = res.url
  296. // break
  297. // case 8:
  298. // this.fTmsorderbillsattachs[7].actId = id
  299. // this.fTmsorderbillsattachs[7].attachName = res.fileName
  300. // this.fTmsorderbillsattachs[7].attachUrl = res.url
  301. // break
  302. // case 9:
  303. // this.fTmsorderbillsattachs[8].actId = id
  304. // this.fTmsorderbillsattachs[8].attachName = res.fileName
  305. // this.fTmsorderbillsattachs[8].attachUrl = res.url
  306. // break
  307. // default:
  308. // this.$message.error('未知错误请刷新后再试');
  309. // }
  310. }
  311. },
  312. init() {
  313. console.log(this.fTmsorderbillsattachs)
  314. this.visible = true
  315. console.log(this.dataForm)
  316. if (this.dataForm.Id) {
  317. lookOver(this.dataForm.Id).then(data => {
  318. console.log(data)
  319. this.dataFormD = data.data
  320. })
  321. }
  322. },
  323. handleSelect(query) {
  324. company(query).then(data => {
  325. console.log(data)
  326. this.optionsProjectTypeItem = data.rows
  327. })
  328. },
  329. // 表单提交
  330. dataFormSubmit() {
  331. this.$refs['dataForm'].validate((valid) => {
  332. if (valid) {
  333. preservation(this.dataForm).then(data => {
  334. if (data && data.code === 200) {
  335. this.$message({
  336. message: '操作成功',
  337. type: 'success',
  338. duration: 1500,
  339. onClose: () => {
  340. this.visible = false
  341. this.$emit('refreshDataList')
  342. }
  343. })
  344. } else {
  345. this.$message.error(data.msg)
  346. }
  347. })
  348. }
  349. })
  350. }
  351. }
  352. }
  353. </script>
  354. <style scoped>
  355. .el-form-item {
  356. width: 49%;
  357. margin-bottom: 20px;
  358. display: inline-block;
  359. }
  360. .el-select {
  361. display: block;
  362. }
  363. .upload-demo {
  364. margin-left: 50px;
  365. }
  366. .avatar-uploader .el-upload {
  367. border: 1px dashed #d9d9d9;
  368. border-radius: 6px;
  369. cursor: pointer;
  370. position: relative;
  371. overflow: hidden;
  372. }
  373. .avatar-uploader .el-upload:hover {
  374. border-color: #409EFF;
  375. }
  376. .avatar-uploader-icon {
  377. font-size: 28px;
  378. color: #8c939d;
  379. width: 178px;
  380. height: 178px;
  381. line-height: 178px;
  382. text-align: center;
  383. }
  384. .avatar {
  385. width: 178px;
  386. height: 178px;
  387. display: block;
  388. }
  389. </style>