safety-archives.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <view class="archives-page">
  3. <scroll-view scroll-y class="scroll-content">
  4. <view class="note mt">食品安全监督公示</view>
  5. <view class="block-item bbline">
  6. <view class="label">单位名称: </view>
  7. <input class="value" maxlength="20" style="width: 100%;" v-model="info.storeInfoName"></input>
  8. </view>
  9. <view class="block-item bbline">
  10. <view class="label">许可证号:</view>
  11. <input class="value" maxlength="20" style="width: 100%;" v-model="info.licenseKey"></input>
  12. </view>
  13. <view class="block-item bbline">
  14. <view class="label">经营地址:</view>
  15. <input class="value" maxlength="20" style="width: 100%;" v-model="info.address"></input>
  16. </view>
  17. <view class="block-item bbline">
  18. <view class="label">主体业态:</view>
  19. <input class="value" maxlength="20" style="width: 100%;" v-model="info.businessFormat"></input>
  20. </view>
  21. <view class="block-item bbline">
  22. <view class="label">经营范围:</view>
  23. <input class="value" maxlength="20" style="width: 100%;" v-model="info.businessScope"></input>
  24. </view>
  25. <view class="block-item">
  26. <view class="label">有效期:</view>
  27. <view class="value" v-if="info.effectiveEndDate" @click="selectDate">
  28. {{ info.effectiveEndDate|formatDate('yyyy-M-d') }}
  29. </view>
  30. <view class="value" v-else @click="selectDate">
  31. 请选择时间
  32. </view>
  33. </view>
  34. <view class="note">商家资质信息公示</view>
  35. <view class="imgs-scroll">
  36. <view class="imgs-list" :style="{ width: 3 * 348 + 40 + 'rpx' }">
  37. <view class="item">
  38. <!-- <u-image width="348rpx" height="348rpx" :src="info.licenseOneUrl"></u-image> -->
  39. <view>营业执照</view>
  40. <u-upload :fileList="fileList1" @afterRead="afterRead1" @delete="deletePic1" name="1"
  41. :previewFullImage="true" :maxCount="1" :width="150" :height="150"></u-upload>
  42. </view>
  43. <view class="item">
  44. <!-- <u-image width="348rpx" height="348rpx" :src="info.licenseTwoUrl"></u-image> -->
  45. <view>经营许可证</view>
  46. <u-upload :fileList="fileList2" @afterRead="afterRead2" @delete="deletePic2" name="2"
  47. :previewFullImage="true" :maxCount="1" :width="150" :height="150"></u-upload>
  48. </view>
  49. </view>
  50. </view>
  51. </scroll-view>
  52. <uni-calendar ref="calendar" class="uni-calendar--hook" :clear-date="true" :insert="false" @confirm="confirm" />
  53. <view class="update-events">
  54. <view class="btn" @click="save">保存</view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import {mapState} from 'vuex';
  60. export default {
  61. data () {
  62. return {
  63. infoUrl: '/storeInfoManageApi/getStoreInfo',
  64. uploadFileUrl: '/storeInfoManageApi/uploadUrl',
  65. saveUrl: '/storeInfoManageApi/update',
  66. storeId: '',
  67. fileList1: [],
  68. fileList2: [],
  69. list: [],
  70. info: {
  71. storeInfoId: '',
  72. licenseOneUrl: '',
  73. licenseTwoUrl: '',
  74. licenseKey: '',
  75. storeInfoName: '',
  76. address: '',
  77. businessFormat: '',
  78. businessScope: '',
  79. effectiveEndDate: ''
  80. },
  81. file1: {},
  82. file2: {},
  83. }
  84. },
  85. computed: {
  86. ...mapState(['storeInfo'])
  87. },
  88. methods: {
  89. getStoreInfo() {
  90. uni.showLoading({
  91. title: '加载中'
  92. });
  93. var dateStr = (new Date()).getTime();
  94. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  95. this.requst({
  96. url: this.infoUrl,
  97. data: {
  98. timestamp: dateStr,
  99. sign: sign,
  100. storeId: this.storeInfo.storeId,
  101. storeUserId: this.storeInfo.storeUserId
  102. },
  103. success: res => {
  104. if (res.data.rtnBean.rtnCode == 0) {
  105. this.info = res.data.obj
  106. let picUrl1 = this.info.licenseOneUrl;
  107. if (picUrl1 !== null && picUrl1 !== '' && picUrl1 !== undefined){
  108. this.fileList1.push({
  109. url: picUrl1
  110. })
  111. }
  112. let picUrl2 = this.info.licenseTwoUrl;
  113. if (picUrl2 !== null && picUrl2 !== '' && picUrl2 !== undefined){
  114. this.fileList2.push({
  115. url: picUrl2
  116. })
  117. }
  118. }
  119. uni.hideLoading();
  120. },
  121. fail: (e) => {
  122. console.log("接口调用失败:" + JSON.stringify(e));
  123. uni.hideLoading();
  124. },
  125. })
  126. },
  127. // 删除图片
  128. deletePic1(event) {
  129. this.fileList1.splice(event.index, 1)
  130. this.info.licenseOneUrl = ''
  131. },
  132. deletePic2(event) {
  133. this.fileList2.splice(event.index, 1)
  134. this.info.licenseTwoUrl = ''
  135. },
  136. // 新增图片
  137. async afterRead1(event) {
  138. // console.log('event :>> ', event);
  139. this.file1 = event.file
  140. let file = event.file
  141. let fileListLen = this.fileList1.length
  142. // lists.map((item) => {
  143. this.fileList1.push({
  144. ...file,
  145. status: 'loading',
  146. // message: '上传中'
  147. })
  148. this.info.licenseOneUrl = this.file1.url
  149. this.uploadFile(1,this.file1.url)
  150. },
  151. uploadFile(type,url) {
  152. uni.showLoading({
  153. title: '上传中'
  154. });
  155. var dateStr = (new Date()).getTime();
  156. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  157. return new Promise((resolve, reject) => {
  158. let a = uni.uploadFile({
  159. url: this.storeInfo.code + this.uploadFileUrl,
  160. filePath: url,
  161. name: 'file',
  162. formData: {
  163. timestamp: dateStr,
  164. sign: sign,
  165. storeId: this.storeInfo.storeId,
  166. storeUserId: this.storeInfo.storeUserId,
  167. type: type
  168. },
  169. success: (res) => {
  170. let data = JSON.parse(res.data)
  171. if (data.rtnBean.rtnCode == 0) {
  172. uni.hideLoading();
  173. uni.showToast({
  174. title: "上传成功",
  175. duration: 3000,
  176. icon: 'none',
  177. });
  178. } else {
  179. uni.hideLoading();
  180. if (data.rtnBean.rtnMsg != '') {
  181. this.$api.msg(data.rtnBean.rtnMsg);
  182. }
  183. }
  184. },
  185. fail: (res) => {
  186. uni.hideLoading();
  187. }
  188. });
  189. })
  190. },
  191. async afterRead2(event) {
  192. console.log('event :>> ', event);
  193. this.file2 = event.file
  194. let file = event.file
  195. let fileListLen = this.fileList2.length
  196. // lists.map((item) => {
  197. this.fileList2.push({
  198. ...file,
  199. status: 'loading',
  200. // message: '上传中'
  201. })
  202. this.info.licenseTwoUrl = this.file2.url
  203. this.uploadFile(2,this.file2.url)
  204. },
  205. selectDate() {
  206. this.$refs.calendar.open();
  207. },
  208. confirm(e) {
  209. console.log('e :>> ', e);
  210. if (e.fulldate != '' && e.fulldate != undefined && e.fulldate != null ) {
  211. this.info.effectiveEndDate = e.fulldate
  212. }
  213. },
  214. save () {
  215. if (this.info.storeInfoName == null || this.info.storeInfoName == '') {
  216. this.$api.msg("请输入单位名称");
  217. return;
  218. } else if (this.info.licenseKey == null || this.info.licenseKey == '') {
  219. this.$api.msg("请输入许可证号");
  220. return;
  221. } else if (this.info.address == null || this.info.address == '') {
  222. this.$api.msg("请输入经营地址");
  223. return;
  224. } else if (this.info.businessFormat == null || this.info.businessFormat == '') {
  225. this.$api.msg("请输入主体业态");
  226. return;
  227. }else if (this.info.businessScope == null || this.info.businessScope == '') {
  228. this.$api.msg("请输入经营范围");
  229. return;
  230. } else if (this.info.effectiveEndDate == null || this.info.effectiveEndDate == '') {
  231. this.$api.msg("请选择有效期");
  232. return;
  233. } else if (this.info.licenseOneUrl == null || this.info.licenseOneUrl == '') {
  234. this.$api.msg("请上传营业执照");
  235. return;
  236. }else if (this.info.licenseTwoUrl == null || this.info.licenseTwoUrl == '') {
  237. this.$api.msg("请上传经营许可证");
  238. return;
  239. }else{
  240. uni.showLoading({
  241. title: '保存中'
  242. });
  243. var dateStr = (new Date()).getTime();
  244. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  245. this.requst({
  246. url: this.saveUrl,
  247. data: {
  248. timestamp: dateStr,
  249. sign: sign,
  250. storeId: this.storeInfo.storeId,
  251. storeUserId: this.storeInfo.storeUserId,
  252. storeInfoName: this.info.storeInfoName,
  253. licenseKey: this.info.licenseKey,
  254. address: this.info.address,
  255. businessFormat: this.info.businessFormat,
  256. businessScope: this.info.businessScope,
  257. effectiveEndDate: this.info.effectiveEndDate,
  258. },
  259. success: res => {
  260. if (res.data.rtnBean.rtnCode == 0) {
  261. uni.showToast({
  262. title: "保存成功",
  263. duration: 3000,
  264. icon: 'none',
  265. });
  266. } else {
  267. if (res.data.rtnBean.rtnMsg != '') {
  268. this.$api.msg(res.data.rtnBean.rtnMsg);
  269. return;
  270. }
  271. }
  272. uni.hideLoading();
  273. },
  274. fail: (e) => {
  275. this.isDisable = false;
  276. console.log("接口调用失败:" + JSON.stringify(e));
  277. uni.hideLoading();
  278. },
  279. });
  280. }
  281. // uni.navigateBack();
  282. }
  283. },
  284. onLoad (options) {
  285. this.getStoreInfo()
  286. }
  287. }
  288. </script>
  289. <style lang="scss" scoped>
  290. .scroll-content {
  291. height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
  292. height: calc(100vh - 120rpx - constant(safe-area-inset-bottom));
  293. }
  294. .note {
  295. width: 100%;
  296. height: 80upx;
  297. @include flexStart;
  298. background-color: $bg-color;
  299. color: $other-color;
  300. padding-left: 20upx;
  301. box-sizing: border-box;
  302. font-size: $font-base;
  303. background-color: rgba(245, 245, 245, 1);
  304. color: rgba(108, 108, 108, 1);
  305. }
  306. .block-item {
  307. margin: 0 20upx;
  308. padding: 24upx 0;
  309. box-sizing: border-box;
  310. @include flexStart(flex-start);
  311. font-size: $font-sm;
  312. .label {
  313. width: 140upx;
  314. min-width: 140upx;
  315. color: $desc-color;
  316. }
  317. .value {
  318. color: $title-color;
  319. }
  320. }
  321. .imgs-scroll {
  322. width: 100vw;
  323. height: 348rpx;
  324. padding: 0 20rpx;
  325. box-sizing: border-box;
  326. margin-top: 20rpx;
  327. }
  328. .imgs-list {
  329. height: 348rpx;
  330. overflow: hidden;
  331. display: flex;
  332. flex-wrap: nowrap;
  333. }
  334. .item {
  335. width: 348rpx;
  336. height: 348rpx;
  337. margin-right: 20upx;
  338. }
  339. .update-events {
  340. width: 100vw;
  341. @include flexCenter;
  342. margin-top: 40rpx;
  343. .btn {
  344. width: 80vw;
  345. height: 80rpx;
  346. border-radius: 40rpx;
  347. background-color: $theme-color;
  348. color: #fff;
  349. @include flexCenter;
  350. }
  351. }
  352. </style>