jyzdj.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <view class="container">
  3. <view class="forms">
  4. <u--form :rules="rules"
  5. labelPosition="left"
  6. :model="yhxx" labelWidth="120"
  7. ref="uForm">
  8. <u-form-item
  9. label="加油站名称"
  10. prop="jyzmc"
  11. borderBottom
  12. ref="item1">
  13. <u--input
  14. v-model="yhxx.jyzmc"
  15. placeholder="请输入加油站名称"
  16. border="none"
  17. ></u--input>
  18. </u-form-item>
  19. <u-form-item
  20. label="统一社会信用代码"
  21. prop="shtyxydm"
  22. borderBottom
  23. ref="item1">
  24. <u--input
  25. v-model="yhxx.shtyxydm"
  26. placeholder="请输入统一社会信用代码"
  27. border="none"
  28. ></u--input>
  29. </u-form-item>
  30. <u-form-item
  31. label="加油站照片"
  32. prop="jyzzp"
  33. borderBottom
  34. placeholder=""
  35. ref="item1">
  36. <view class="zpbox" v-if="!yhxx.jyzzp" @click="uploadimg">
  37. <uni-icons type="plusempty" size="30"></uni-icons>
  38. </view>
  39. <view v-else>
  40. <image mode="widthFix" :src="yhxx.jyzzp" style="width: 120rpx;"></image>
  41. </view>
  42. </u-form-item>
  43. <u-form-item
  44. label="法人姓名"
  45. prop="frxm"
  46. borderBottom
  47. ref="item1">
  48. <u--input
  49. v-model="yhxx.frxm"
  50. placeholder="请输入法人姓名"
  51. border="none"
  52. ></u--input>
  53. </u-form-item>
  54. <u-form-item
  55. label="法人电话"
  56. prop="frdh"
  57. borderBottom
  58. ref="item1">
  59. <u--input
  60. v-model="yhxx.frdh"
  61. placeholder="请输入法人电话"
  62. border="none"
  63. ></u--input>
  64. </u-form-item>
  65. <u-form-item
  66. label="负责人姓名"
  67. prop="fzrxm"
  68. borderBottom
  69. ref="item1">
  70. <u--input
  71. v-model="yhxx.fzrxm"
  72. placeholder="请输入负责人姓名"
  73. border="none"
  74. ></u--input>
  75. </u-form-item>
  76. <u-form-item
  77. label="负责人电话"
  78. prop="fzrdh"
  79. borderBottom
  80. ref="item1">
  81. <u--input
  82. v-model="yhxx.fzrdh"
  83. placeholder="请输入负责人电话"
  84. border="none"
  85. ></u--input>
  86. </u-form-item>
  87. <u-form-item
  88. label="加油站地址"
  89. prop="jyzxz"
  90. borderBottom
  91. ref="item1">
  92. <u--input
  93. v-model="yhxx.jyzxz"
  94. placeholder="请输入加油站地址"
  95. border="none"
  96. ></u--input>
  97. </u-form-item>
  98. <u-form-item
  99. label="管辖地派出所"
  100. prop="sspcs"
  101. borderBottom
  102. ref="item1">
  103. <uni-data-picker placeholder="请选择管辖地派出所" popup-title="请选择管辖地派出所" :localdata="dataTreepcs" v-model="yhxx.sspcs"
  104. @change="onchange" @nodeclick="onnodeclick" @popupopened="onpopupopened" @popupclosed="onpopupclosed">
  105. </uni-data-picker>
  106. </u-form-item>
  107. <u-form-item
  108. label="管辖地社区"
  109. prop="sssq"
  110. borderBottom
  111. ref="item1">
  112. <uni-data-picker placeholder="请选择社区" popup-title="请选择社区" :localdata="dataTree" v-model="yhxx.sssq"
  113. @change="onchange" @nodeclick="onnodeclick2" @popupopened="onpopupopened" @popupclosed="onpopupclosed">
  114. </uni-data-picker>
  115. </u-form-item>
  116. </u--form>
  117. <view @click="dengji" class="djbutton">登记</view>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. import { jyzdjSave } from "@/api/jfsc.js"
  123. import { getDeptList,putfiles } from "@/api/my.js"
  124. import { baseurl } from "../../common/setting"
  125. export default{
  126. data(){
  127. return{
  128. dataTree:[],
  129. dataTreepcs:[],
  130. show: true,
  131. columns:[],
  132. columnData: [],
  133. fileList1: [],
  134. yhxx:{
  135. jyzmc:'',
  136. shtyxydm:'',
  137. frxm:'',
  138. },
  139. rules:{
  140. 'jyzmc': {
  141. type: 'string',
  142. required: true,
  143. message: '请填写加油站名称',
  144. trigger: ['blur', 'change']
  145. },
  146. 'shtyxydm': {
  147. type: 'string',
  148. required: true,
  149. message: '请填写社会统一信用代码',
  150. trigger: ['blur', 'change']
  151. },
  152. 'frxm': {
  153. type: 'string',
  154. required: true,
  155. message: '请填写法人姓名',
  156. trigger: ['blur', 'change']
  157. }
  158. }
  159. }
  160. },
  161. onLoad() {
  162. uni.showLoading({
  163. title: '加载中'
  164. });
  165. getDeptList().then(res=>{
  166. res.data.forEach((vs,v)=>{
  167. vs.text = vs.label
  168. })
  169. this.dataTreepcs = res.data
  170. uni.hideLoading()
  171. }).finally(()=>{
  172. uni.hideLoading()
  173. })
  174. },
  175. methods:{
  176. dengji(){
  177. this.$refs.uForm.validate().then(res => {
  178. uni.showLoading({
  179. title: '加载中'
  180. });
  181. jyzdjSave(this.yhxx).then(res=>{
  182. uni.showToast({
  183. success:'登记成功'
  184. })
  185. uni.switchTab({
  186. url: "/pages/my/index", // 确保 url 是正确的
  187. });
  188. this.$refs.uForm.resetFields()
  189. }).finally(()=>{
  190. uni.hideLoading()
  191. })
  192. }).catch(errors => {
  193. })
  194. },
  195. back(){
  196. uni.switchTab({
  197. url: "/pages/my/index", // 确保 url 是正确的
  198. });
  199. },
  200. goPage(url){
  201. uni.navigateTo({
  202. url:url
  203. })
  204. },
  205. onnodeclick(e) {
  206. getDeptList(e.value).then(res=>{
  207. res.data.forEach((vs,v)=>{
  208. vs.text = vs.label
  209. })
  210. this.dataTree = res.data
  211. }).finally(()=>{
  212. uni.hideLoading()
  213. })
  214. },
  215. onnodeclick2(e){
  216. },
  217. onpopupopened(e) {
  218. console.log('popupopened');
  219. },
  220. onpopupclosed(e) {
  221. console.log('popupclosed');
  222. },
  223. onchange(e) {
  224. console.log('onchange:', e);
  225. },
  226. // 删除图片
  227. deletePic(event) {
  228. this[`fileList${event.name}`].splice(event.index, 1)
  229. },
  230. uploadimg(){
  231. uni.chooseImage({
  232. success: (chooseImageRes) => {
  233. const tempFilePaths = chooseImageRes.tempFilePaths;
  234. uni.uploadFile({
  235. url: baseurl+'/blade-resource/oss/endpoint/put-file', //仅为示例,非真实的接口地址
  236. filePath: tempFilePaths[0],
  237. name: 'file',
  238. // 客户端认证参数
  239. header:{
  240. Authorization:'Basic c2FiZXI6c2FiZXJfc2VjcmV0'
  241. },
  242. formData: {
  243. 'file': tempFilePaths[0]
  244. },
  245. success: (res) => {
  246. let datalink = JSON.parse(res.data)
  247. if(datalink.code == 200) {
  248. this.$set(this.yhxx,'jyzzp',datalink.data.link)
  249. //this.yhxx.jyzzp = datalink.data.link
  250. this.$u.func.showToast({title:'图片上传成功'})
  251. }
  252. },
  253. fail: (err) => {
  254. console.log(err);
  255. }
  256. });
  257. }
  258. });
  259. //this.userInfo.jyzzp
  260. },
  261. }
  262. }
  263. </script>
  264. <style lang="scss">
  265. /deep/ .uni-navbar__content{
  266. border-bottom: none !important;
  267. }
  268. .container{
  269. height: 100vh;
  270. padding: 24rpx 24rpx 0;
  271. box-sizing: border-box;
  272. background: #F8F8F8;
  273. }
  274. .zpbox{
  275. width: 120rpx;
  276. height: 120rpx;
  277. border: 1px dotted #ddd;
  278. text-align: center;
  279. line-height: 120rpx;
  280. display: inline-block;
  281. border-radius: 3px;
  282. }
  283. .forms{
  284. width: calc(100% - 24rpx);
  285. margin: auto;
  286. background: #FFF;
  287. border-radius: 15px;
  288. padding:24rpx;
  289. box-sizing: border-box;
  290. }
  291. .djbutton{
  292. height: 88rpx;
  293. background: linear-gradient( to top, #65CBFF 0%, #0260FE 100%);
  294. border-radius: 44rpx;
  295. opacity: 0.5;
  296. font-family: PingFangSC, PingFang SC;
  297. font-weight: 500;
  298. font-size: 36rpx;
  299. color: #FFFFFF;
  300. line-height: 88rpx;
  301. text-align: center;
  302. font-style: normal;
  303. margin-top: 48rpx;
  304. }
  305. /deep/ .input-value-border{
  306. border: 0 !important;
  307. }
  308. </style>