add.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div class="intro-add">
  3. <nav-bar></nav-bar>
  4. <div class="page-container">
  5. <!-- 基本信息 -->
  6. <div class="card">
  7. <van-panel title="来访信息" >
  8. <template #header>
  9. <span></span>
  10. </template>
  11. <!-- <template #header>-->
  12. <!-- <van-cell title="状态">-->
  13. <!-- <template #extra>-->
  14. <!-- <span :style="{color:getState(getDictLabel(visitInfo.status,'out_in_approve_status'))}">-->
  15. <!-- {{getDictLabel(visitInfo.status,'out_in_approve_status') }}-->
  16. <!-- </span>-->
  17. <!-- </template>-->
  18. <!-- </van-cell>-->
  19. <!-- </template>-->
  20. <div class="panel-box">
  21. <select-cell
  22. title="出入人员"
  23. :prop="prop"
  24. is-row
  25. @itemInfo="getItemInfo"
  26. v-model="selectedUser.id"
  27. :data-list="userList"
  28. required>
  29. </select-cell>
  30. <van-cell title="证件号码" :value="selectedUser.idCard"></van-cell>
  31. <div class="upload-box" v-if="selectedUser.imgFile && selectedUser.imgFile.length > 0">
  32. <span>证件照</span>
  33. <van-cell>
  34. <div
  35. class="nfc-img van-hairline--surround"
  36. v-for="(v, i) in selectedUser.imgFile"
  37. :key="v"
  38. @click="preView(selectedUser.imgFile)">
  39. <img :src="imgUrl(v)" alt="" />
  40. </div>
  41. </van-cell>
  42. </div>
  43. <van-cell title="单位" :value="selectedUser.companyName"></van-cell>
  44. <van-cell title="出入事由" :value="selectedUser.reasons"></van-cell>
  45. <van-cell title="介绍信" v-if="selectedUser.letterFile && selectedUser.letterFile.length > 0">
  46. <template #right-icon>
  47. <div class="file-box">
  48. <p class="van-ellipsis" v-for="(v, i) in selectedUser.letterFile"
  49. :key="v.url"
  50. @click="previewFile(v)">{{v.name}}</p>
  51. </div>
  52. </template>
  53. </van-cell>
  54. <van-cell title="出入类型" :value="getDictLabel(selectedUser.type,'out_in_type')"></van-cell>
  55. <van-field
  56. v-model="formData.accompanyingPerson"
  57. required
  58. rows="1"
  59. autosize
  60. :maxlength="200"
  61. placeholder="请输入"
  62. label="陪同人员"></van-field>
  63. <div class="upload-box" >
  64. <span class="required">核验结果</span>
  65. <van-cell>
  66. <uploader :maxCount="2" v-model="formData.checkImage"/>
  67. </van-cell>
  68. </div>
  69. <date-cell required title="到达时间" :max-date="maxData" v-model="formData.arrivalTime" date-type="datetime" />
  70. <!-- <date-cell title="离开时间" :max-date="maxData" v-model="formData.departureTime" date-type="datetime" />-->
  71. </div>
  72. <div class="big-btn-box" >
  73. <van-button type="info" size="large" @click="onSubmit">确认保存</van-button>
  74. </div>
  75. </van-panel>
  76. </div>
  77. </div>
  78. </div>
  79. </template>
  80. <script>
  81. import DateCell from "@/components/dateCell/index.vue";
  82. import Uploader from "@/components/upload/gxuploader.vue";
  83. import {formatDate} from "@/filters/filter";
  84. import {mapGetters} from "vuex";
  85. import {imgUrl} from "@/utils";
  86. import { ImagePreview } from 'vant'
  87. import {userList, userRegister} from './api'
  88. export default {
  89. components: {Uploader, DateCell},
  90. data(){
  91. return {
  92. maxData:new Date(),
  93. visitId:null,
  94. userList:[],
  95. selectedUser:{},
  96. prop:{
  97. label:'userName',
  98. value:'id'
  99. },
  100. formData:{
  101. letterUserId:null,
  102. arrivalTime:null,
  103. departureTime:null,
  104. accompanyingPerson:null,
  105. checkImage:null,
  106. },
  107. dicts:['out_in_approve_status','out_in_type']
  108. }
  109. },
  110. computed:{
  111. ...mapGetters(['orgId','id','dictionary'])
  112. },
  113. mounted(){
  114. this.getUserList();
  115. },
  116. methods:{
  117. imgUrl,formatDate,
  118. onSubmit(){
  119. if(!this.selectedUser.id){
  120. this.$toast('请选择出入人员');
  121. return
  122. }
  123. if(!this.formData.accompanyingPerson){
  124. this.$toast('请输入陪同人员');
  125. return
  126. }
  127. if(!this.formData.checkImage){
  128. this.$toast('请上传审核结果');
  129. return
  130. }
  131. if(!this.formData.arrivalTime){
  132. this.$toast('请选择到达时间');
  133. return
  134. }
  135. let data = {
  136. ...this.formData,
  137. letterId:this.selectedUser.letterId,
  138. checkImage:this.formData.checkImage.map(v=>{return v.imgPath}).toString(','),
  139. letterUserId:this.selectedUser.id,
  140. orgId:this.orgId,
  141. }
  142. //alert(JSON.stringify(data))
  143. userRegister(data).then(res=>{
  144. this.$toast.success('提交成功');
  145. this.$router.replace({
  146. name:'visitRecord',
  147. path:'/visitRecord',
  148. params:{event:'refresh'},
  149. });
  150. })
  151. },
  152. getItemInfo(item){
  153. this.selectedUser = item;
  154. },
  155. previewFile(file){
  156. this.openFilePreview(file);
  157. },
  158. getUserList(){
  159. let data = {
  160. orgId:this.orgId,
  161. arrivalTime:formatDate(new Date(),'YYYY-MM-DD')
  162. }
  163. userList(data).then(res=>{
  164. this.userList = res.data.map(v=>{
  165. v.imgFile = v.imgFile.split(',');
  166. if(v.letterFile && v.letterFile.length >0){
  167. v.letterFile = v.letterFile.map(str=>{
  168. return JSON.parse(str)
  169. })
  170. }
  171. return v
  172. })
  173. })
  174. },
  175. preView(val) {
  176. if(Array.isArray(val)){
  177. let arr = val.map(v=>{
  178. return imgUrl(v);
  179. })
  180. ImagePreview(arr);
  181. }else {
  182. ImagePreview([imgUrl(val)]);
  183. }
  184. },
  185. }
  186. }
  187. </script>
  188. <style lang="scss">
  189. .intro-add{
  190. .van-card{
  191. padding: 20px;
  192. }
  193. .card-cell-box{
  194. width: 70%;
  195. .van-cell{
  196. padding: 10px;
  197. &::after{
  198. left:10px;
  199. right:10px;
  200. }
  201. }
  202. .van-cell__title{
  203. flex:.25;
  204. }
  205. .van-cell__value{
  206. flex:.75;
  207. }
  208. }
  209. }
  210. </style>
  211. <style scoped lang="scss">
  212. .intro-add{
  213. height: 100%;
  214. overflow: hidden;
  215. }
  216. .page-container{
  217. height: calc(100vh - 94px);
  218. overflow: auto;
  219. padding: 20px;
  220. }
  221. .flex-box{
  222. display: flex;
  223. justify-content: space-between;
  224. align-items: center;
  225. >span{
  226. margin: 0 20px;
  227. }
  228. }
  229. .card{
  230. margin-bottom: 20px;
  231. box-shadow: 0 10px 10px #eaeaea;
  232. }
  233. .card:last-child{
  234. margin-bottom: 0;
  235. }
  236. .panel-box{
  237. -padding:0 20px;
  238. }
  239. .panel-box-item{
  240. height: 36px;
  241. line-height: 36px;
  242. }
  243. .item-label{
  244. width: 100%;
  245. display: flex;
  246. justify-content: right;
  247. align-items: center;
  248. }
  249. .item-value{
  250. width: 100%;
  251. display: flex;
  252. justify-content: left;
  253. align-items: center;
  254. }
  255. .upload-box{
  256. padding: 0 30px;
  257. display: flex;
  258. >span{
  259. display: inline-block;
  260. height: 160px;
  261. width: 200px;
  262. line-height: 160px;
  263. font-size: 28px;
  264. color:#999;
  265. >i{
  266. font-style: normal;
  267. color: #ee0a24;
  268. }
  269. }
  270. .required::before{
  271. content: '*';
  272. color: #ee0a24;
  273. position: absolute;
  274. left: 14px;
  275. }
  276. }
  277. .goods-card{
  278. width: 100%;
  279. display: flex;
  280. align-items: center;
  281. padding: 10px;
  282. background-color: #fff;
  283. .card-img-box{
  284. width: 200px;
  285. height: 200px;
  286. margin-right: 10px;
  287. >img{
  288. width: 100%;
  289. height: 100%;
  290. object-fit: cover;
  291. border-radius: 10px;
  292. }
  293. }
  294. }
  295. .file-box{
  296. width: 70%;
  297. display: flex;
  298. justify-content: flex-end;
  299. color:#008cd6;
  300. }
  301. .big-btn-box{
  302. padding: 20px;
  303. }
  304. .nfc-img {
  305. display: inline-block;
  306. width: 140px;
  307. height: 140px;
  308. margin: 0 10px;
  309. position: relative;
  310. > img {
  311. width: 100%;
  312. height: 100%;
  313. border: none;
  314. }
  315. > span {
  316. position: absolute;
  317. padding: 0 10px;
  318. bottom: 0;
  319. left: 0;
  320. display: block;
  321. width: 100%;
  322. background-color: rgba(0, 0, 0, 0.2);
  323. color: #eaeaea;
  324. font-size: 20px;
  325. overflow: hidden;
  326. text-overflow: ellipsis;
  327. white-space: nowrap;
  328. line-height: 30px;
  329. height: 30px;
  330. }
  331. }
  332. </style>