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-input
  144. v-else
  145. disabled
  146. :value="formdData.companiesOrcResult.postalAddress"
  147. ></u-input>
  148. </u-form-item>
  149. </view>
  150. <!-- <view class="content">
  151. <u-form-item
  152. prop="postalAddress"
  153. :required="true"
  154. label="单位通讯地址:"
  155. >
  156. <u-input
  157. disabled
  158. :value="formdData.companiesOrcResult.postalAddress"
  159. ></u-input>
  160. </u-form-item>
  161. </view> -->
  162. </u-form>
  163. </view>
  164. </view>
  165. </view>
  166. </template>
  167. <script>
  168. import vvSelectArea from "@/components/vv-select-area/vv-select-area";
  169. import { getRegiong } from "@/api/companiesRegistered";
  170. export default {
  171. components: {
  172. vvSelectArea,
  173. },
  174. async created() {
  175. Object.keys(this.form).forEach((ele) => {
  176. this.form[ele] = this.formdData.companiesOrcResult[ele];
  177. });
  178. if (this.formdData.companiesOrcResult.region) {
  179. this.region = this.formdData.companiesOrcResult.region.split(",");
  180. }
  181. try {
  182. let { data } = await getRegiong();
  183. this.areas = data;
  184. } catch (error) {}
  185. },
  186. onReady() {
  187. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  188. this.$refs.uForm.setRules(this.rules);
  189. this.$emit("update:companiesInformationRef", this.$refs.uForm);
  190. },
  191. data() {
  192. return {
  193. form: {
  194. regNum: null,
  195. name: null,
  196. address: null,
  197. person: null,
  198. address: null,
  199. },
  200. rules: {
  201. type: [
  202. {
  203. required: true,
  204. },
  205. ],
  206. address: [
  207. {
  208. required: true,
  209. message: "单位注册地址不能为空不能为空",
  210. trigger: "blur",
  211. },
  212. ],
  213. person: [
  214. {
  215. required: true,
  216. message: "法人代表不能为空",
  217. trigger: "blur",
  218. },
  219. ],
  220. name: [
  221. {
  222. required: true,
  223. message: "单位名称不能为空",
  224. trigger: "blur",
  225. },
  226. ],
  227. regNum: [
  228. {
  229. required: true,
  230. message: "统一社会信用代码不能为空",
  231. trigger: "blur",
  232. },
  233. ],
  234. location: [
  235. {
  236. required: true,
  237. message: "地理位置不能为空",
  238. trigger: "blur",
  239. },
  240. ],
  241. postalAddress: [
  242. {
  243. required: true,
  244. message: "通讯地址不能为空",
  245. trigger: "blur",
  246. },
  247. ],
  248. region: [
  249. {
  250. required: true,
  251. message: "所在区域不能为空",
  252. trigger: "blur",
  253. },
  254. ],
  255. },
  256. region: null, //单位所属区域
  257. show: true,
  258. areas: [], // 地址list
  259. };
  260. },
  261. props: {
  262. formdData: {
  263. type: Object,
  264. default: () => ({}),
  265. },
  266. companiesInformationRef: {
  267. type: Object,
  268. default: () => ({}),
  269. },
  270. },
  271. watch: {
  272. region(newVal) {
  273. this.$emit(
  274. "update:formdData",
  275. Object.assign({
  276. ...this.formdData,
  277. companiesOrcResult: {
  278. ...this.formdData.companiesOrcResult,
  279. region: this.region.join(","),
  280. },
  281. })
  282. );
  283. },
  284. },
  285. methods: {
  286. handleForm(key) {
  287. console.log(this.formdData);
  288. },
  289. //获取位置
  290. handleGetMap() {
  291. uni.authorize({
  292. scope: "scope.userLocation",
  293. success: (res) => {
  294. uni.chooseLocation({
  295. success: (res) => {
  296. this.$emit(
  297. "update:formdData",
  298. Object.assign({
  299. ...this.formdData,
  300. companiesOrcResult: {
  301. ...this.formdData.companiesOrcResult,
  302. location: `${res.latitude},${res.longitude}`,
  303. postalAddress: res.address,
  304. },
  305. })
  306. );
  307. // console.log("位置名称:" + res.name);
  308. // console.log("详细地址:" + res.address);
  309. // console.log("纬度:" + res.latitude);
  310. // console.log("经度:" + res.longitude);
  311. },
  312. });
  313. },
  314. fail(err) {},
  315. });
  316. },
  317. },
  318. };
  319. </script>
  320. <style lang="scss">
  321. .iconMap {
  322. display: flex;
  323. justify-content: space-between;
  324. }
  325. .informationTitle {
  326. margin-bottom: 30rpx;
  327. font-size: 30;
  328. }
  329. .contentItems {
  330. width: 100%;
  331. border-radius: 6px;
  332. background: #fff;
  333. margin: 0rpx auto 30rpx;
  334. padding: 20rpx 30rpx 20rpx;
  335. .content {
  336. border-bottom: 1px solid rgb(242, 242, 242);
  337. }
  338. .content:last-child {
  339. border-bottom: none;
  340. }
  341. .title {
  342. font-size: 30rpx;
  343. color: black;
  344. letter-spacing: 3rpx;
  345. }
  346. .message {
  347. text-align: right;
  348. width: 380rpx;
  349. font-size: 30rpx;
  350. color: rgb(146, 146, 146);
  351. // white-space: nowrap;
  352. // /* 禁止文本换行 */
  353. // overflow: hidden;
  354. // /* 隐藏超出容器的文本 */
  355. // text-overflow: ellipsis;
  356. /* 使用省略号表示被截断的文本 */
  357. }
  358. }
  359. </style>