store.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view>
  3. <my_form ref="form" :form="form" @onUploading="onUploading" @isUncomplete="isUncomplete" requiredFieldOnly
  4. @interrupt="interrupt" />
  5. <view style="height: 70px;" />
  6. <view class="footer">
  7. <view class="add" @click="uncomplete || loading ? '' : submit()" :class="uncomplete ? 'forbidden' : ''"
  8. hover-class=" navigator-hover">
  9. <u-loading-icon v-if="loading" />
  10. <block v-else>
  11. 提交
  12. </block>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. sa_storeid: 0,
  22. form: [],
  23. uncomplete: true,
  24. loading: false,
  25. }
  26. },
  27. async onLoad() {
  28. uni.setNavigationBarTitle({
  29. title: '新增门店'
  30. });
  31. this.form = [{
  32. key: "storename",
  33. type: "text",
  34. label: "门店名称",
  35. isMust: true,//是否必填
  36. value: "",
  37. }, {
  38. key: "area",
  39. type: "text",
  40. label: "面积(m²)",
  41. isMust: true,//是否必填
  42. value: "",
  43. inputmode: 'digit',
  44. }, {
  45. key: "leader_hrid",
  46. type: "route",
  47. path: "/team/userCenter/selectUser?title=选择负责人",
  48. isRadio: true,
  49. label: "负责人姓名",
  50. isMust: true,//是否必填
  51. value: [],
  52. showValue: [],
  53. interrupt: true
  54. }, {
  55. key: "phonenumber",
  56. type: "text",
  57. label: "负责人电话",
  58. isMust: true,//是否必填
  59. value: "",
  60. inputmode: 'number',
  61. disabled: true,
  62. verify: [this.getReg("phonenumber")]
  63. }, {
  64. key: "sale_phonenmber",
  65. type: "text",
  66. label: "门店售前电话",
  67. isMust: false,//是否必填
  68. value: "",
  69. inputmode: 'number',
  70. verify: [this.getReg("phonenumber")]
  71. }, {
  72. key: "service_phonenmber",
  73. type: "text",
  74. label: "门店售后电话",
  75. isMust: false,//是否必填
  76. value: "",
  77. inputmode: 'number',
  78. verify: [this.getReg("phonenumber")]
  79. }, {
  80. key: "storetype",
  81. type: "radio",
  82. label: "门店类型",
  83. value: "直营",
  84. options: [{
  85. label: "直营",
  86. name: "直营",
  87. marginRight: 60
  88. }, {
  89. label: "分销",
  90. name: "分销",
  91. }]
  92. }, {
  93. key: "markettype",
  94. type: "customClass",
  95. label: "门店卖场类型",
  96. isMust: false,//是否必填
  97. isMultipleChoice: false,//是否多选
  98. value: '',// 多选[] 单选 ""
  99. list: await this.getCustomClass('storetype')
  100. }, {
  101. key: "selectMap",
  102. type: "route",
  103. path: "/select/place/index",
  104. label: "门店地址",
  105. keys: ["latitude", "longitude", "province", "city", "county", "address"],
  106. isRadio: true,
  107. showValue: [],
  108. isMust: true,//是否必填
  109. value: {},
  110. }, {
  111. key: "attachmentids",
  112. type: "upload",
  113. label: "门店照片",
  114. accept: "image",
  115. placeholder: "仅单张",
  116. ownertable: "temporary",
  117. ownerid: 999,
  118. usetype: 'default',
  119. allowUpload: true,
  120. allowDelete: true,
  121. maxCount: 1,
  122. value: []
  123. }];
  124. },
  125. methods: {
  126. isUncomplete(uncomplete) {
  127. this.uncomplete = uncomplete;
  128. },
  129. onUploading(e) {
  130. if (e) {
  131. this.copyUncomplete = this.uncomplete;
  132. this.uncomplete = true;
  133. } else {
  134. this.uncomplete = this.copyUncomplete;
  135. }
  136. },
  137. interrupt(item, selected, index) {
  138. console.log(item)
  139. console.log(selected)
  140. console.log(index)
  141. switch (item.key) {
  142. case "leader_hrid":
  143. item.showValue = [selected.name];
  144. item.value = [selected.sys_enterprise_hrid];
  145. this.$refs.form.setItem(index, item)
  146. this.$refs.form.setValue(index + 1, selected.phonenumber, true)
  147. break;
  148. case "selectMap":
  149. item.showValue = [selected.name];
  150. item.value = selected;
  151. this.$refs.form.setItem(index, item, true)
  152. break;
  153. }
  154. },
  155. submit() {
  156. this.loading = true;
  157. let that = this;
  158. this.$refs.form.submit().then(data => {
  159. data.leader_hrid = data.leader_hrid.value;
  160. this.$Http.basic({
  161. "id": 20240410095302,
  162. "content": {
  163. "sa_storeid": this.sa_storeid,
  164. ...data
  165. }
  166. }).then(async res => {
  167. console.log("创建门店", res)
  168. if (this.cutoff(res.msg)) return;
  169. if (data.files.temporarys.length) await this.$Http.basic({
  170. "classname": "system.attachment.Attachment",
  171. "method": "createFileLink",
  172. "content": {
  173. ownertable: 'sa_store',
  174. ownerid: res.data.sa_storeid,
  175. usetype: 'default',
  176. attachmentids: data.files.temporarys
  177. }
  178. })
  179. if (data.files.linksids.length) await this.$Http.basic({
  180. "classname": "system.attachment.Attachment",
  181. "method": "deleteFileLink",
  182. "content": {
  183. linksids: data.files.linksids
  184. }
  185. })
  186. this.loading = false;
  187. uni.showModal({
  188. title: '创建成功',
  189. content: '门店新增成功!是否立即前往',
  190. cancelText: '返回',
  191. confirmText: '立即前往',
  192. success: ({ confirm }) => {
  193. if (confirm) {
  194. uni.redirectTo({
  195. url: '/store/center/detail?id=' + res.data.sa_storeid,
  196. })
  197. } else {
  198. uni.navigateBack();
  199. }
  200. },
  201. })
  202. })
  203. })
  204. },
  205. },
  206. onShow() {
  207. /* let a11 = {
  208. address: "浙江省嘉兴市南湖区望湖路585号",
  209. city: "嘉兴市",
  210. county: "南湖区",
  211. district: "南湖区",
  212. latitude: 30.74803,
  213. longitude: 120.786539,
  214. name: "翡翠花园",
  215. province: "浙江省"
  216. }
  217. if (location) {
  218. location.county = location.district;
  219. this.location = location;
  220. this.$refs.form.setValue(this.form.findIndex(v => v.label == '门店地址'), location.name || this.getCity(location))
  221. } */
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .footer {
  227. position: fixed;
  228. bottom: 0;
  229. width: 100vw;
  230. height: 65px;
  231. background: #FFFFFF;
  232. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  233. box-sizing: border-box;
  234. padding: 5px 10px;
  235. .add {
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. width: 100%;
  240. height: 45px;
  241. background: #C30D23;
  242. border-radius: 5px;
  243. font-family: PingFang SC, PingFang SC;
  244. font-size: 14px;
  245. color: #FFFFFF;
  246. }
  247. .forbidden {
  248. opacity: .6;
  249. }
  250. }
  251. </style>