acquisitionInformation.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <view class="wrap">
  3. <view class='content1'>
  4. <view class='row content-item'>
  5. <view class="left" @click='show1=true'>
  6. <view>{{warehouseName}}</view>
  7. <u-icon name="arrow-right" color=""></u-icon>
  8. <u-picker @confirm="warehousechange" range-key='warehouseName' mode="selector" v-model="show1" :range="warehouseList"></u-picker>
  9. </view>
  10. </view>
  11. <view class="content-item">
  12. <view class="left">收购信息</view>
  13. <view class='row textarea'>
  14. <textarea placeholder-style="color:#AFB3BF;" placeholder="输入收购信息,不超过2000个字" maxlength="2000" v-model="textareaValue"></textarea>
  15. <view class="textarea-left">
  16. <view class="clear" @click="clear()">清除全部</view>
  17. </view>
  18. <view class="textarea-bottom">{{textareaValue?textareaValue.length:'0'}}/2000字</view>
  19. </view>
  20. <view class='row row_css'>
  21. 显示在易粮易运收购信息中
  22. <!-- <u-checkbox activeColor="#19be6b" v-model="value" @change="checkBoxChange">显示在易粮易运收购信息中</u-checkbox> -->
  23. <view class="right">
  24. <u-switch v-model="value" active-color="#19be6b" inactive-color="#eee" size='40' @change="checkBoxChange"></u-switch>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="bottom-btn">
  30. <u-button type="primary" class="submit" hover-class="none" @click="submit()">提交</u-button>
  31. </view>
  32. <u-toast ref="uToast" />
  33. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  34. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='提示'
  35. :showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  36. <u-modal v-model="isShowAlert1" :title-style="{fontSize: '18px',fontWeight:'500'}"
  37. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='收购信息'
  38. :showCancelButton='false' :content="content1" @confirm="alertBtn1" @cancel="cancelClick"></u-modal>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. mapState
  44. } from 'vuex';
  45. export default {
  46. components: {
  47. },
  48. data() {
  49. return {
  50. isSHowBtn: true,
  51. isShowAlert: false,
  52. isShowAlert1: false,
  53. content: '当前登入信息验证失败,是否重新登录?',
  54. content1: '确定提交收购信息?',
  55. textareaValue: '',
  56. value: false,
  57. warehouseName: '暂无仓库',
  58. warehouseList: [],
  59. show1: false,
  60. isEdit: false,
  61. sgId: '',
  62. id: ''
  63. }
  64. },
  65. onLoad(options) {
  66. },
  67. // #ifndef MP
  68. onNavigationBarButtonTap(e) {
  69. const index = e.index;
  70. if (index === 0) {
  71. this.navTo('/pages/set/set');
  72. } else if (index === 1) {
  73. // #ifdef APP-PLUS
  74. const pages = getCurrentPages();
  75. const page = pages[pages.length - 1];
  76. const currentWebview = page.$getAppWebview();
  77. currentWebview.hideTitleNViewButtonRedDot({
  78. index
  79. });
  80. // #endif
  81. uni.navigateTo({
  82. url: '/pages/notice/notice'
  83. })
  84. }
  85. },
  86. // #endif
  87. computed: {
  88. ...mapState(['hasLogin', 'userInfo']),
  89. },
  90. onShow() {
  91. this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
  92. console.log("checkSession", res)
  93. if (res.data.data == "INVALID") {
  94. this.isShowAlert = true;
  95. // uni.showModal({
  96. // title: '提示',
  97. // content: '当前登入信息验证失败,是否重新登录?',
  98. // showCancel: true,
  99. // confirmText: '登录',
  100. // success: (e) => {
  101. // if (e.confirm) {
  102. // uni.navigateTo({
  103. // url: '/pages/public/login'
  104. // })
  105. // }
  106. // },
  107. // fail: () => {},
  108. // complete: () => {}
  109. // })
  110. }
  111. this.init()
  112. })
  113. console.log("hasLogin", this.hasLogin)
  114. },
  115. methods: {
  116. init() {
  117. var that = this
  118. this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouseSelfApp', {
  119. compId: uni.getStorageSync('pcUserInfo').compId,
  120. }).then(res => {
  121. if (res.data.data.length > 0) {
  122. uni.hideLoading()
  123. // let _showData = uni.getStorageSync("erpSelectWarehous")
  124. // let _showCWData = uni.getStorageSync("erpSelectWarehousCW")
  125. this.warehouseList = res.data.data
  126. let _storangewarehouseName = uni.getStorageSync("depotAcquisition_warehouseName")
  127. if (_storangewarehouseName) {
  128. this.warehouseName = _storangewarehouseName
  129. } else {
  130. this.warehouseName = res.data.data[0].warehouseName
  131. uni.setStorageSync("depotAcquisition_warehouseName", this.warehouseName)
  132. }
  133. that.$api.doRequest('get', '/acquisitionInfo/getInfo', {
  134. commonId: uni.getStorageSync("userInfo").id,
  135. warehouseName:uni.getStorageSync("depotAcquisition_warehouseName")
  136. }).then(res1 => {
  137. if (res1.data.code == 200) {
  138. if (res1.data.data) {
  139. that.isEdit = true
  140. that.value = res1.data.data.checkFlag == '0' ? false : true
  141. console.log(that.value)
  142. that.warehouseName = res1.data.data.warehouseName
  143. that.textareaValue = res1.data.data.acquisitionInformation
  144. that.id = res1.data.data.id
  145. } else {
  146. that.textareaValue = ''
  147. that.isEdit = false
  148. that.value = false
  149. }
  150. }
  151. })
  152. } else {
  153. this.warehouseList = []
  154. this.warehouseName = '暂无仓库'
  155. }
  156. })
  157. // switch (this.status) {
  158. // case '已隐藏':
  159. // break;
  160. // case '显示中':
  161. // break;
  162. // }
  163. },
  164. warehousechange(e) {
  165. this.warehouseName = this.warehouseList[e[0]].warehouseName
  166. this.warehouseId = this.warehouseList[e[0]].id
  167. uni.setStorageSync("depotAcquisition_warehouseName", this.warehouseName)
  168. this.init()
  169. },
  170. /**
  171. * 统一跳转接口,拦截未登录路由
  172. * navigator标签现在默认没有转场动画,所以用view
  173. */
  174. navTo(url) {
  175. if (!this.hasLogin) {
  176. url = '/pages/public/login';
  177. }
  178. uni.navigateTo({
  179. url
  180. })
  181. },
  182. alertBtn() {
  183. uni.navigateTo({
  184. url: '/pages/public/login'
  185. })
  186. },
  187. alertBtn1() {
  188. uni.showLoading({
  189. title: "加载中...",
  190. mask: true
  191. })
  192. let _flag = ''
  193. console.log(this.value)
  194. if (this.value) {
  195. _flag = 1
  196. } else {
  197. _flag = 0
  198. }
  199. if(!this.textareaValue&&_flag==1){
  200. this.$api.msg('收购信息不能为空!')
  201. return
  202. }
  203. let _obj = {
  204. warehouseName: this.warehouseName,
  205. acquisitionInformation: this.textareaValue,
  206. checkFlag: _flag,
  207. followFlag: "0",
  208. commonId:uni.getStorageSync("userInfo").id
  209. }
  210. if (this.isEdit) {
  211. _obj.id = this.id
  212. }
  213. this.$api.doRequest('post', '/acquisitionInfo/api/addAcquisition', _obj).then(res => {
  214. if (res.data.code == 200) {
  215. uni.hideLoading()
  216. this.$api.msg('添加成功')
  217. uni.navigateBack()
  218. }else{
  219. this.$api.msg('添加失败')
  220. this.isShowAlert = false
  221. }
  222. })
  223. },
  224. cancelClick() {
  225. this.isShowAlert = false
  226. },
  227. checkBoxChange(e) {
  228. this.value = e
  229. // this.alertBtn1()
  230. // console.log("value----", this.value)
  231. },
  232. submit() {
  233. this.isShowAlert1 = true
  234. // this.$api.msg('提交成功')
  235. // this.$api.msg('提交失败')
  236. },
  237. clear(){
  238. this.textareaValue=''
  239. }
  240. }
  241. }
  242. </script>
  243. <style lang='scss' scoped>
  244. page {
  245. background: #F5F6FA;
  246. }
  247. .wrap {
  248. /* background: #fff; */
  249. margin: 10px;
  250. border-radius: 10px;
  251. /* padding: 10px; */
  252. height: calc(100vh - 55px);
  253. }
  254. .content-item{
  255. /* height: 104rpx; */
  256. border-radius: 14rpx;
  257. background: #fff;
  258. padding: 40rpx 30rpx;
  259. margin-bottom: 20rpx;
  260. }
  261. .left{
  262. align-items: center;
  263. color: #333333;
  264. font-size: 34rpx;
  265. font-weight: 600;
  266. }
  267. .row {
  268. display: flex;
  269. justify-content: space-between;
  270. position: relative;
  271. /* border-bottom: 1px solid #EEEEEE; */
  272. input {
  273. font-size: 28rpx;
  274. // color: #333333;
  275. }
  276. .left {
  277. display: flex;
  278. align-items: center;
  279. color: #333333;
  280. font-size: 34rpx;
  281. font-weight: 600;
  282. }
  283. }
  284. .row_css{
  285. font-size: 26rpx;
  286. color: #333333;
  287. margin-top: 60rpx;
  288. font-weight: 500;
  289. }
  290. .textarea {
  291. background: #F9F9FA;
  292. font-size: 28rpx;
  293. text-align: left;
  294. width: 100%;
  295. padding: 30rpx 30rpx;
  296. border-radius: 5px;
  297. margin-top: 30rpx;
  298. height: 46vh;
  299. padding-bottom: 20rpx;
  300. color: #333 ;
  301. }
  302. .textarea textarea{
  303. height: 90%;
  304. }
  305. .textarea-left{
  306. position: absolute;
  307. bottom: 12rpx;
  308. left: 20rpx;
  309. color: #606266;
  310. }
  311. .textarea-bottom {
  312. position: absolute;
  313. bottom: 20rpx;
  314. right: 20rpx;
  315. color: #AFB3BF;
  316. }
  317. .submit {
  318. width: 90%;
  319. background: #22C572;
  320. border-radius: 50rpx;
  321. }
  322. .clear {
  323. /* width: 90%; */
  324. background: #ffffff;
  325. color: #22C572;
  326. border:1px solid #22C572;
  327. border-radius: 50rpx;
  328. font-size: 28rpx;
  329. padding: 9rpx 24rpx;
  330. }
  331. .bottom-btn {
  332. position: fixed;
  333. bottom: 0rpx;
  334. left:0;
  335. width: 100%;
  336. padding:20rpx;
  337. }
  338. </style>