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.

add-work-order.vue 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view class="bg">
  3. <view class="title_wrap"><text class="title">基本信息</text></view>
  4. <car-number-input @numberInputResult="carNumber" :defaultStr="state.form.vehiclePlate"></car-number-input>
  5. <u-form label-width="230" :model="state.form" ref="uForm" :label-style='labelStyle'>
  6. <u-form-item label="车牌颜色" :left-icon='`${$imgUrl}issuance/point-form.png`' :left-icon-style='leftIcon'
  7. borderBottom>
  8. <u-input v-model="state.vehiclePlateColorStr" type="select" @click="show1 = true" input-align='right'/>
  9. </u-form-item>
  10. <u-form-item label="姓名" :left-icon='`${$imgUrl}issuance/point-form.png`' :left-icon-style='leftIcon'
  11. borderBottom>
  12. <u-input placeholder='请输入姓名' v-model="state.form.customerName" maxlength="18"
  13. inputAlign="right" />
  14. </u-form-item>
  15. <u-form-item label="联系方式" :left-icon='`${$imgUrl}issuance/point-form.png`' :left-icon-style='leftIcon'
  16. borderBottom>
  17. <u-input placeholder='请输入手机号码' type="number" v-model="state.form.customerTel" maxlength="11"
  18. inputAlign="right" />
  19. </u-form-item>
  20. </u-form>
  21. </view>
  22. <view class="bg">
  23. <view class="title">工单信息</view>
  24. <u-form label-width="230" :model="state.form" ref="uForm" :label-style='labelStyle' borderBottom>
  25. <u-form-item label="工单类型" :left-icon='`${$imgUrl}issuance/point-form.png`' :left-icon-style='leftIcon'
  26. borderBottom>
  27. <u-input v-model="state.questionTypeStr" type="select" @click="show2 = true" input-align='right'/>
  28. </u-form-item>
  29. <u-form-item label="是否ETC用户" :left-icon='`${$imgUrl}issuance/point-form.png`' :left-icon-style='leftIcon'
  30. borderBottom>
  31. <u-input v-model="state.etcUserStr" type="select" @click="show3 = true" input-align='right'/>
  32. </u-form-item>
  33. <u-form-item label="事件发生日期" :left-icon='`${$imgUrl}issuance/point-form.png`' :left-icon-style='leftIcon'
  34. borderBottom>
  35. <picker mode="date" @change="bindDateChange">
  36. <view class="picker" v-if="!state.form.eventOccurrenceTime">
  37. 请选择日期
  38. </view>
  39. <view class="data">
  40. {{state.form.eventOccurrenceTime}}
  41. </view>
  42. </picker>
  43. </u-form-item>
  44. <u-form-item label="客户诉求" :left-icon='`${$imgUrl}issuance/point-form.png`' :left-icon-style='leftIcon'
  45. borderBottom>
  46. </u-form-item>
  47. <textarea v-model="state.form.appeal" style="border: 1rpx dashed rgb(192, 196, 204);min-height: 200rpx; width: 100%;border-radius: 18rpx;padding: 20rpx;box-sizing: border-box;" placeholder="请输入述求" auto-height adjust-position></textarea>
  48. <u-form-item label="其他佐证材料" :left-icon='`${$imgUrl}issuance/point-form.png`' :left-icon-style='leftIcon'
  49. borderBottom>
  50. <text class="common-word">(不限于图片、文件、不超过5个。)</text>
  51. </u-form-item>
  52. <view class="down-wrap" v-for="(item,index) in state.supportingMaterialsUrlShow" :key="index">
  53. <text>附件{{index+1}}</text>
  54. <view>
  55. <text class="down" @click="down(item,index)">预览</text>
  56. <text class="down" @click="deleteFile(index)">删除</text>
  57. </view>
  58. </view>
  59. <button type="default" class="ui-btn-another" @click="addFile()">+添加附件</button>
  60. </u-form>
  61. </view>
  62. <view class="action">
  63. <button type="default" class="ui-btn" @click="savaHandle()">
  64. 提交
  65. </button>
  66. </view>
  67. <!-- 选择车牌颜色 -->
  68. <u-select v-model="show1" :list="state.colorRange" @confirm="changeColor"></u-select>
  69. <!-- 工单类型 -->
  70. <u-select v-model="show2" :list="state.questionTypeRange" @confirm="changeQuestionType"></u-select>
  71. <!-- -->
  72. <u-select v-model="show3" :list="state.etcUserRange" @confirm="changeEtcUser"></u-select>
  73. </template>
  74. <script setup lang="ts">
  75. import { navTo,msg,uploadFile, getFullImageUrl } from "@/utils/utils";
  76. import { reactive,ref } from "vue";
  77. import carNumberInput from "@/components/car-number-input/car-number-input.vue";
  78. import { onLoad } from "@dcloudio/uni-app";
  79. import { getItem } from "@/utils/storage.ts"
  80. import {requestNew} from "@/utils/network/request.js";
  81. import {selfServiceUserAdd} from "@/utils/network/api.js";
  82. import { getCodeName } from '@/datas/queryKey.js'
  83. interface uploadResponce {
  84. imageUrl: string
  85. }
  86. const labelStyle = {
  87. color: "#004576",
  88. fontSize: "28rpx",
  89. }
  90. const leftIcon = {
  91. height: '100%',
  92. width: '8rpx',
  93. display: 'flex',
  94. 'align-items': 'center',
  95. 'margin-right': '4rpx',
  96. }
  97. const show1 = ref(false)
  98. const show2 = ref(false)
  99. const show3 = ref(false)
  100. const state = reactive({
  101. form: {
  102. customerName: "",
  103. customerTel: "",
  104. vehiclePlate: "",
  105. vehiclePlateColor: "",
  106. questionType:"",
  107. etcUser:"",
  108. eventOccurrenceTime:"", //2016-09-01 00:00:00
  109. appeal:"",
  110. supportingMaterialsUrl:"",
  111. },
  112. supportingMaterialsUrlShow:[],
  113. etcUserStr: '',
  114. vehiclePlateColorStr: '',
  115. questionTypeStr:"",
  116. colorRange: [],
  117. questionTypeRange:[],
  118. etcUserRange:[
  119. {value: 1, label: "是"},
  120. {value: 0, label: "否"},
  121. ],
  122. })
  123. onLoad((option : any) => {
  124. state.colorRange = setDicCode('VEHICLE_COLOR_TYPE')
  125. state.questionTypeRange = setDicCode('SELF_SERVICE_TYPE')
  126. });
  127. // 设置字典
  128. const setDicCode = (codeName:string) => {
  129. let dic = getItem('key')[codeName];
  130. if (!dic) return []
  131. let arr = []
  132. for (var k = 0; k < dic.length; k++) {
  133. let obj = {};
  134. obj['value'] = dic[k]['code']
  135. obj['label'] = dic[k]['name']
  136. arr.push(obj)
  137. }
  138. return arr
  139. }
  140. const getCarColorName = (code: string) => {
  141. return getCodeName('VEHICLE_COLOR_TYPE', code)
  142. }
  143. const getSelfTypeName = (code: string) => {
  144. return getCodeName('SELF_SERVICE_TYPE', code)
  145. }
  146. //车牌号输入
  147. const carNumber = (val : any) => {
  148. state.form.vehiclePlate = val.trim();
  149. };
  150. const changeColor = (item) => {
  151. state.form.vehiclePlateColor = item[0].value
  152. state.vehiclePlateColorStr = item[0].label
  153. console.log(item)
  154. }
  155. const changeQuestionType = (item) => {
  156. state.form.questionType = item[0].value
  157. state.questionTypeStr = item[0].label
  158. console.log(item)
  159. }
  160. const changeEtcUser = (item) => {
  161. state.form.etcUser = item[0].value
  162. state.etcUserStr = item[0].label
  163. console.log(item)
  164. }
  165. const bindDateChange=(e)=>{
  166. console.log('picker发送选择改变,携带值为', e.detail.value)
  167. state.form.eventOccurrenceTime= e.detail.value
  168. }
  169. const savaHandle = () => {
  170. if(!state.form.vehiclePlate){
  171. msg('请输入车牌号');
  172. return;
  173. }
  174. if(!state.form.vehiclePlateColor){
  175. msg('请选择车牌颜色');
  176. return;
  177. }
  178. if(!state.form.customerName){
  179. msg('请输入姓名');
  180. return;
  181. }
  182. if(!state.form.customerTel){
  183. msg('请输入手机号码');
  184. return;
  185. }
  186. if(!state.form.questionType){
  187. msg('请选择工单类型');
  188. return;
  189. }
  190. if(!state.form.etcUser){
  191. msg('请选择是否ETC用户');
  192. return;
  193. }
  194. if(!state.form.eventOccurrenceTime){
  195. msg('请选择事件发生日期');
  196. return;
  197. }
  198. if(!state.form.appeal){
  199. msg('请输入述求');
  200. return;
  201. }
  202. if(state.supportingMaterialsUrlShow && state.supportingMaterialsUrlShow.length === 0){
  203. msg('请上传其他佐证材料');
  204. return;
  205. }
  206. let params = JSON.parse(JSON.stringify(state.form))
  207. params.eventOccurrenceTime = state.form.eventOccurrenceTime+" 00:00:00"
  208. params.supportingMaterialsUrl = state.supportingMaterialsUrlShow.toString()
  209. const options = {
  210. type: 2,
  211. data: params,
  212. method: "POST",
  213. showLoading: true,
  214. };
  215. requestNew(selfServiceUserAdd, options).then((res) => {
  216. msg("新增自助工单成功")
  217. setTimeout(()=>{
  218. uni.navigateBack()
  219. },1500)
  220. });
  221. }
  222. const addFile=()=>{
  223. const count = 5 - state.supportingMaterialsUrlShow.length
  224. uni.chooseMessageFile({
  225. count: count,
  226. type: 'all',
  227. success (res) {
  228. // tempFilePath可以作为img标签的src属性显示图片
  229. console.log("res",res)
  230. var files=res.tempFiles
  231. for(var i = 0;i < files.length; i++){
  232. uploadFile(files[i]['path']).then((data: uploadResponce) => {
  233. state.supportingMaterialsUrlShow.push(data.imageUrl);
  234. })
  235. }
  236. }
  237. })
  238. }
  239. const down=(item,index)=>{
  240. const lastDotIndex = item.lastIndexOf(".");
  241. const result = item.substring(lastDotIndex+1);
  242. if(result=='jpg' || result=='png'){
  243. uni.previewImage({
  244. urls:[getFullImageUrl(item)],
  245. longPressActions: {
  246. itemList: ['发送给朋友', '保存图片', '收藏'],
  247. success: function(data) {
  248. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  249. },
  250. fail: function(err) {
  251. console.log(err.errMsg);
  252. }
  253. }
  254. });
  255. }else{
  256. uni.downloadFile({
  257. url: getFullImageUrl(item),
  258. success(res) {
  259. console.log("下载",res)
  260. const filePath = res.tempFilePath
  261. uni.openDocument({
  262. filePath: filePath,
  263. showMenu: true, // 关键点
  264. success: function (res) {
  265. msg("打开文档成功");
  266. },
  267. fail: function (err) {
  268. msg("打开文档失败");
  269. }
  270. });
  271. },
  272. fail: function (err) {
  273. msg("下载文档失败");
  274. console.log("err", err)
  275. },
  276. complete(res) {
  277. }
  278. })
  279. }
  280. }
  281. const deleteFile=(index)=>{
  282. state.supportingMaterialsUrlShow.splice(index,1)
  283. }
  284. </script>
  285. <style lang="scss" scoped>
  286. .bg {
  287. background-color: white;
  288. width: 88%;
  289. margin: 0 auto;
  290. margin-top: 20rpx;
  291. border-radius: 12px;
  292. border: 1px solid #FFFFFF;
  293. padding: 20rpx;
  294. overflow: hidden;
  295. .title_wrap {
  296. display: flex;
  297. font-weight: 400;
  298. margin-bottom: 40rpx;
  299. .title {
  300. font-size: 30rpx;
  301. color: #01243A;
  302. }
  303. }
  304. .des {
  305. font-weight: 400;
  306. font-size: 28rpx;
  307. color: #01243A;
  308. line-height: 56rpx;
  309. margin-top: 10rpx;
  310. text-indent: 1rem;
  311. }
  312. }
  313. .action {
  314. position: absolute;
  315. left: 0;
  316. height: 188rpx;
  317. background-color: #fff;
  318. border-radius: 30rpx 30rpx 0 0;
  319. width: 100vw;
  320. display: flex;
  321. align-items: center;
  322. justify-content: center;
  323. flex-direction: column;
  324. margin-top: 20rpx;
  325. }
  326. .picker{
  327. text-align: right;
  328. color: rgb(192, 196, 204);
  329. }
  330. .data{
  331. text-align: right;
  332. }
  333. .five{
  334. color: rgb(195,188,157);
  335. }
  336. .down-wrap{
  337. display: flex;
  338. justify-content: space-between;
  339. margin-bottom: 35rpx;
  340. .down{
  341. width: 100rpx;
  342. height: 50rpx;
  343. border-radius: 20rpx;
  344. background:linear-gradient(90deg, #CCB375 0%, #E7D398 100%);
  345. font-weight: 400;
  346. font-size: 24rpx;
  347. color: #FFFFFF;
  348. text-align: center;
  349. line-height: 50rpx;
  350. display: inline-block;
  351. margin-left: 16rpx;
  352. }
  353. }
  354. </style>