companiesInformation.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <!-- @format -->
  2. <template>
  3. <view class="container">
  4. <view style="color: #3c9cff" class="informationTitle">企业信息</view>
  5. <view class="informationContent">
  6. <view class="contentItems">
  7. <u-form
  8. ref="uForm"
  9. :model="formdData.companiesOrcResult"
  10. :rules="rules"
  11. labelWidth="140"
  12. labelPosition="top"
  13. >
  14. <view class="content">
  15. <u-form-item
  16. :required="true"
  17. style="border-bottom: 1px solid rgb(242, 242, 242)"
  18. label="单位类别:"
  19. prop="type"
  20. >
  21. <!-- <view class="message">{{
  22. formdData.companiesOrcResult.type
  23. }}</view> -->
  24. <u-input
  25. disabled
  26. :value="formdData.companiesOrcResult.type"
  27. ></u-input>
  28. </u-form-item>
  29. </view>
  30. <view class="content">
  31. <u-form-item
  32. :required="true"
  33. label="统一社会信用代码:"
  34. prop="regNum"
  35. >
  36. <u-input
  37. @blur="
  38. () => {
  39. this.$emit('update:formdData', {
  40. ...this.formdData,
  41. companiesOrcResult: {
  42. ...this.formdData.companiesOrcResult,
  43. regNum: form.regNum,
  44. },
  45. });
  46. }
  47. "
  48. v-model="form.regNum"
  49. ></u-input> </u-form-item
  50. ></view>
  51. <view class="content">
  52. <u-form-item :required="true" label="单位名称:" prop="name">
  53. <u-input
  54. @blur="
  55. () => {
  56. this.$emit('update:formdData', {
  57. ...this.formdData,
  58. companiesOrcResult: {
  59. ...this.formdData.companiesOrcResult,
  60. name: form.name,
  61. },
  62. });
  63. }
  64. "
  65. v-model="form.name"
  66. ></u-input> </u-form-item
  67. ></view>
  68. <view class="content">
  69. <u-form-item :required="true" label="登录用户名:">
  70. <!-- <view
  71. style="
  72. width: 380rpx;
  73. font-size: 30rpx;
  74. color: rgb(146, 146, 146);
  75. "
  76. >{{ formdData.companiesOrcResult.regNum }}</view
  77. > -->
  78. <u-input
  79. disabled
  80. :value="formdData.companiesOrcResult.regNum"
  81. ></u-input>
  82. </u-form-item>
  83. </view>
  84. <view class="content">
  85. <u-form-item prop="region" :required="true" label="单位所属区域:">
  86. <vvSelectArea
  87. :list="areas"
  88. v-model="region"
  89. placeholder="请选择所在区域"
  90. ></vvSelectArea> </u-form-item
  91. ></view>
  92. <view class="content">
  93. <u-form-item :required="true" label="单位注册地址:">
  94. <u-input
  95. @blur="
  96. () => {
  97. this.$emit('update:formdData', {
  98. ...this.formdData,
  99. companiesOrcResult: {
  100. ...this.formdData.companiesOrcResult,
  101. address: form.address,
  102. },
  103. });
  104. }
  105. "
  106. v-model="form.address"
  107. ></u-input>
  108. </u-form-item>
  109. </view>
  110. <view class="content">
  111. <u-form-item :required="true" label="法人代表/负责人:">
  112. <u-input
  113. @blur="
  114. () => {
  115. this.$emit('update:formdData', {
  116. ...this.formdData,
  117. companiesOrcResult: {
  118. ...this.formdData.companiesOrcResult,
  119. person: form.person,
  120. },
  121. });
  122. }
  123. "
  124. v-model="form.person"
  125. ></u-input>
  126. </u-form-item>
  127. </view>
  128. <view class="content">
  129. <u-form-item prop="location" :required="true" label="单位地理位置:">
  130. <view
  131. class="iconMap"
  132. v-if="!formdData.companiesOrcResult.location"
  133. >
  134. <view></view>
  135. <u-icon
  136. @click="handleGetMap"
  137. name="map-fill"
  138. color="#909399"
  139. size="30"
  140. ></u-icon>
  141. </view>
  142. <view v-else>{{ formdData.companiesOrcResult.location }}</view>
  143. </u-form-item>
  144. </view>
  145. <view class="content">
  146. <u-form-item
  147. prop="postalAddress"
  148. :required="true"
  149. label="单位通讯地址:"
  150. >
  151. <!-- <view class="message">{{
  152. formdData.companiesOrcResult.postalAddress
  153. }}</view> -->
  154. <u-input
  155. disabled
  156. :value="formdData.companiesOrcResult.postalAddress"
  157. ></u-input>
  158. </u-form-item>
  159. </view>
  160. </u-form>
  161. </view>
  162. </view>
  163. </view>
  164. </template>
  165. <script>
  166. import vvSelectArea from "@/components/vv-select-area/vv-select-area";
  167. import { getRegiong } from "@/api/companiesRegistered";
  168. export default {
  169. components: {
  170. vvSelectArea,
  171. },
  172. async created() {
  173. Object.keys(this.form).forEach((ele) => {
  174. this.form[ele] = this.formdData.companiesOrcResult[ele];
  175. });
  176. if (this.formdData.companiesOrcResult.region) {
  177. this.region = this.formdData.companiesOrcResult.region;
  178. }
  179. try {
  180. let { data } = await getRegiong();
  181. this.areas = data;
  182. } catch (error) {}
  183. },
  184. onReady() {
  185. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  186. this.$refs.uForm.setRules(this.rules);
  187. this.$emit("update:companiesInformationRef", this.$refs.uForm);
  188. },
  189. data() {
  190. return {
  191. form: {
  192. regNum: null,
  193. name: null,
  194. address: null,
  195. person: null,
  196. address: null,
  197. },
  198. rules: {
  199. type: [
  200. {
  201. required: true,
  202. },
  203. ],
  204. address: [
  205. {
  206. required: true,
  207. message: "单位注册地址不能为空不能为空",
  208. trigger: "blur",
  209. },
  210. ],
  211. person: [
  212. {
  213. required: true,
  214. message: "法人代表不能为空",
  215. trigger: "blur",
  216. },
  217. ],
  218. name: [
  219. {
  220. required: true,
  221. message: "单位名称不能为空",
  222. trigger: "blur",
  223. },
  224. ],
  225. regNum: [
  226. {
  227. required: true,
  228. message: "统一社会信用代码不能为空",
  229. trigger: "blur",
  230. },
  231. ],
  232. location: [
  233. {
  234. required: true,
  235. message: "地理位置不能为空",
  236. trigger: "blur",
  237. },
  238. ],
  239. postalAddress: [
  240. {
  241. required: true,
  242. message: "通讯地址不能为空",
  243. trigger: "blur",
  244. },
  245. ],
  246. region: [
  247. {
  248. required: true,
  249. message: "所在区域不能为空",
  250. trigger: "blur",
  251. },
  252. ],
  253. },
  254. region: null, //单位所属区域
  255. show: true,
  256. areas: [], // 地址list
  257. };
  258. },
  259. props: {
  260. formdData: {
  261. type: Object,
  262. default: () => ({}),
  263. },
  264. companiesInformationRef: {
  265. type: Object,
  266. default: () => ({}),
  267. },
  268. },
  269. watch: {
  270. region(newVal) {
  271. console.log(this.formdData, this.region);
  272. this.$emit(
  273. "update:formdData",
  274. Object.assign({
  275. ...this.formdData,
  276. companiesOrcResult: {
  277. ...this.formdData.companiesOrcResult,
  278. region: this.region.join(","),
  279. },
  280. })
  281. );
  282. },
  283. },
  284. methods: {
  285. handleForm(key) {
  286. console.log(this.formdData);
  287. },
  288. //获取位置
  289. handleGetMap() {
  290. uni.authorize({
  291. scope: "scope.userLocation",
  292. success: (res) => {
  293. uni.chooseLocation({
  294. success: (res) => {
  295. this.$emit(
  296. "update:formdData",
  297. Object.assign({
  298. ...this.formdData,
  299. companiesOrcResult: {
  300. ...this.formdData.companiesOrcResult,
  301. location: `${res.latitude},${res.longitude}`,
  302. postalAddress: res.address,
  303. },
  304. })
  305. );
  306. // console.log("位置名称:" + res.name);
  307. // console.log("详细地址:" + res.address);
  308. // console.log("纬度:" + res.latitude);
  309. // console.log("经度:" + res.longitude);
  310. },
  311. });
  312. },
  313. fail(err) {},
  314. });
  315. },
  316. },
  317. };
  318. </script>
  319. <style lang="scss">
  320. .iconMap {
  321. display: flex;
  322. justify-content: space-between;
  323. }
  324. .informationTitle {
  325. margin-bottom: 30rpx;
  326. font-size: 30;
  327. }
  328. .contentItems {
  329. width: 100%;
  330. border-radius: 6px;
  331. background: #fff;
  332. margin: 0rpx auto 30rpx;
  333. padding: 20rpx 30rpx 20rpx;
  334. .content {
  335. border-bottom: 1px solid rgb(242, 242, 242);
  336. }
  337. .content:last-child {
  338. border-bottom: none;
  339. }
  340. .title {
  341. font-size: 30rpx;
  342. color: black;
  343. letter-spacing: 3rpx;
  344. }
  345. .message {
  346. text-align: right;
  347. width: 380rpx;
  348. font-size: 30rpx;
  349. color: rgb(146, 146, 146);
  350. // white-space: nowrap;
  351. // /* 禁止文本换行 */
  352. // overflow: hidden;
  353. // /* 隐藏超出容器的文本 */
  354. // text-overflow: ellipsis;
  355. /* 使用省略号表示被截断的文本 */
  356. }
  357. }
  358. </style>