移动端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

supplyAdd.vue 8.7 KiB

il y a 2 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 2 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 2 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="app-container" :style="{height:height+'px'}">
  3. <navBar :title="pageTit" background="0" positionType="fixed"></navBar>
  4. <van-form @submit="submitInteraction">
  5. <div class="block_box">
  6. <div class="block_tt"><i></i>发布信息</div>
  7. <van-field
  8. readonly
  9. clickable
  10. name="picker"
  11. :value="value"
  12. label="供求类型"
  13. placeholder="点击选择供求类型"
  14. @click="showPicker = true"
  15. required
  16. :rules="[{ required:true }]"
  17. />
  18. <van-popup v-model="showPicker" position="bottom">
  19. <van-picker
  20. show-toolbar
  21. :columns="columns"
  22. @confirm="onConfirm"
  23. @cancel="showPicker = false"
  24. />
  25. </van-popup>
  26. <van-field v-model="form.projectName" label="项目名称" placeholder="请输入项目名称" required :rules="[{ required:true }]"/>
  27. <van-field v-model="form.location" label="项目地址" placeholder="请输入项目地址" required :rules="[{ required:true }]"/>
  28. <van-field v-model="form.realname" label="姓名" placeholder="请输入姓名" required :rules="[{ required:true }]"/>
  29. <van-field v-model="form.phone" label="联系电话" placeholder="请输入联系电话" required :rules="[{ required:true }]"/>
  30. <van-field v-model="form.projectContent" label="项目详情" type="textarea" autosize placeholder="请输入项目详情" required :rules="[{ required:true }]"/>
  31. </div>
  32. <div class="block_box">
  33. <div class="block_tt"><i></i>上传相关附件</div>
  34. <div style="padding: 0 16px;">
  35. <van-uploader :after-read="afterRead" :before-delete="deleteFile" v-model="fileList" :max-count="5" />
  36. </div>
  37. <p style="color: #FE1313;margin-top: 20PX;padding-left: 15px;">*请上传jpg/png文件,文件大小不超过5MB</p>
  38. </div>
  39. <div class="submit">
  40. <van-button round block type="info" color="#0DBCAA" native-type="submit">发布</van-button>
  41. </div>
  42. </van-form>
  43. </div>
  44. </template>
  45. <script>
  46. import { getMember , userDemand , updateDemand , selectDemand , base64Attach , showImg , deleteUserImg ,supplyDetail} from "@/api/user/index";
  47. import { getInfo } from "@/api/login/index";
  48. import {Dialog} from "vant";
  49. import navBar from "@/components/common/nav_bar.vue";
  50. import {base64Upload} from "@/api/register";
  51. export default {
  52. name: "supplyAdd",
  53. components: { navBar },
  54. data() {
  55. return {
  56. height:0,
  57. pageTit:'',
  58. value: '',
  59. showPicker: false,
  60. columns:['供应','需求'],
  61. fileList:[],
  62. form:{
  63. projectName:'',
  64. location:'',
  65. realname:'',
  66. phone:'',
  67. projectContent:'',
  68. logintime:'',
  69. deptId:100,
  70. supplyDemandType:''
  71. },
  72. file:{
  73. tableName:'t_transaction_supply_demand',
  74. tableId:'',
  75. files:[],
  76. fileType:'',
  77. bizPath:'transaction'
  78. },
  79. upLoadList:[]
  80. };
  81. },
  82. created() {
  83. this.height = document.body.clientHeight;
  84. console.log(this.$route.query.type)
  85. if (this.$route.query.type == 'update'){
  86. this.getInteraction();
  87. this.pageTit = '修改供求';
  88. }else{
  89. this.getInfo();
  90. this.pageTit = '发布供求';
  91. }
  92. },
  93. methods: {
  94. afterRead(file) {
  95. // 此时可以自行将文件上传至服务器
  96. let params1 = {
  97. file:file.content
  98. }
  99. base64Upload(params1).then((r1) => {
  100. this.upLoadList.push(r1.fileName);
  101. })
  102. // for ( var i = 0 ; i < this.fileList.length ; i++){
  103. // if(this.fileList[i].url == undefined&&this.fileList!='') {
  104. // this.fileList[i] = {url:this.fileList[i].content, id: '', isImage: true};
  105. // }
  106. // }
  107. },
  108. deleteFile(elIndex){
  109. // deleteUserImg(elIndex.id).then(response => {});
  110. // if(elIndex.id != ''){
  111. // deleteUserImg(elIndex.id).then(response => {});
  112. // }
  113. return (file, name) => {
  114. let fileIndex = name.index
  115. this.fileList[elIndex].splice(fileIndex, 1)
  116. this.upLoadList[elIndex].splice(fileIndex, 1)
  117. }
  118. },
  119. onConfirm(value, index) {
  120. this.value = value;
  121. this.showPicker = false;
  122. this.form.supplyDemandType = index + 1 ;
  123. },
  124. getInfo(){
  125. getInfo().then(response => {
  126. getMember(response.user.userId).then(response => {
  127. this.form.realname = response.data.realname;
  128. this.form.phone = response.data.phone;
  129. this.form.memberId = response.data.id;
  130. });
  131. });
  132. },
  133. getInteraction(){
  134. supplyDetail(this.$route.query.id).then(response => {
  135. this.form.projectName = response.data.projectName;
  136. this.form.location = response.data.location;
  137. this.form.projectContent = response.data.projectContent;
  138. this.form.realname = response.data.realname;
  139. this.form.phone = response.data.phone;
  140. this.form.id = this.$route.query.id;
  141. this.form.supplyDemandType = response.data.supplyDemandType;
  142. this.getDicts("supply_demand_type").then(res => {
  143. this.value = this.selectDictLabel(res.data,response.data.supplyDemandType);
  144. });
  145. showImg(response.data.id).then(responseSecond => {
  146. for (var i = 0 ; i < responseSecond.data.length ; i++){
  147. this.fileList.push({url:'/api'+responseSecond.data[i].fileUrl,id:responseSecond.data[i].id})
  148. }
  149. });
  150. });
  151. },
  152. submitInteraction(){
  153. this.form.logintime = this.getNowFormatDate();
  154. this.form.fileUrl = this.upLoadList.join(',');
  155. if(this.$route.query.type == 'update'){
  156. this.file.tableId = this.$route.query.id ;
  157. updateDemand(this.form).then(response => {
  158. // this.$toast.loading({
  159. // message: "上传中...",
  160. // forbidClick: true,
  161. // duration: 0,
  162. // });
  163. // for (var i = 0 ; i < this.fileList.length ; i++){
  164. // if(this.fileList[i].url.indexOf('http://') == -1&&this.fileList!=''){
  165. // this.file.files.push(this.fileList[i].url);
  166. // }
  167. // }
  168. Dialog.confirm({
  169. title: '系统提示',
  170. message: '修改成功',
  171. confirmButtonText: '确定',
  172. showCancelButton:false
  173. }).then(() => {
  174. self.location=document.referrer;
  175. })
  176. // base64Attach(this.file).then(response => {
  177. // if (response.code == 200){
  178. // Dialog.confirm({
  179. // title: '系统提示',
  180. // message: '修改成功',
  181. // confirmButtonText: '确定',
  182. // showCancelButton:false
  183. // }).then(() => {
  184. // self.location=document.referrer;
  185. // })
  186. // }
  187. // });
  188. });
  189. }else{
  190. userDemand(this.form).then(response => {
  191. this.file.tableId = response.data;
  192. this.$toast.loading({
  193. message: "上传中...",
  194. forbidClick: true,
  195. duration: 0,
  196. });
  197. // for(var i = 0 ; i < this.fileList.length ; i++){
  198. // this.file.files.push(this.fileList[i].url);
  199. // }
  200. Dialog.confirm({
  201. title: '系统提示',
  202. message: '发布成功',
  203. confirmButtonText: '确定',
  204. showCancelButton:false
  205. }).then(() => {
  206. self.location=document.referrer;
  207. })
  208. // base64Attach(this.file).then(response => {
  209. // if (response.code == 200){
  210. // Dialog.confirm({
  211. // title: '系统提示',
  212. // message: '发布成功',
  213. // confirmButtonText: '确定',
  214. // showCancelButton:false
  215. // }).then(() => {
  216. // self.location=document.referrer;
  217. // })
  218. // }
  219. // });
  220. });
  221. }
  222. },
  223. },
  224. };
  225. </script>
  226. <style scoped lang="scss">
  227. .app-container {
  228. background-color: #F4F8FB;
  229. height: calc(100vh - 0Px);
  230. overflow-y: scroll;
  231. }
  232. .block_box{
  233. width: 94%;
  234. margin: 3vw auto;
  235. background: #ffffff;
  236. padding: 3vw 0;
  237. border-radius: 15Px;
  238. overflow: hidden;
  239. .block_tt{
  240. font-size: 20Px;
  241. display: flex;
  242. align-items: center;
  243. padding: 1.6vh 3vw;
  244. line-height: 1;
  245. font-weight: bold;
  246. i{
  247. display: block;
  248. width: 4Px;
  249. height: 16Px;
  250. background: #0CBEA6;
  251. margin-right: 5PX;
  252. border-radius: 5PX;
  253. }
  254. /*border-left: 3Px solid #0CBEA6;*/
  255. }
  256. }
  257. .submit{
  258. position: absolute;
  259. bottom: 5%;
  260. width: 90%;
  261. left: 5%;
  262. p{
  263. text-align: center;
  264. margin-bottom: 0.2rem;
  265. span{
  266. color: #007E72;
  267. }
  268. }
  269. }
  270. </style>