price.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <view class="price">
  3. <view class="picker-btn">
  4. <view class="btn">
  5. <button class="oper-btn" type="primary" @click="showPicker=true">
  6. {{$t('approval.information')}}
  7. </button>
  8. </view>
  9. <view class="btn">
  10. <button class="oper-btn" type="primary" @click="sureChangePrice">
  11. {{$t('approval.confirmPrice')}}
  12. </button>
  13. </view>
  14. </view>
  15. <u-sticky bgColor="#fff">
  16. <view class="change-price-title">
  17. <view class="change-price-item">
  18. {{$t('approval.adjustmentRange')}}:
  19. <view class="inp">
  20. <u-input type="number" v-model="changePrice" />
  21. </view>
  22. <view class="btn">
  23. <button class="oper-btn" type="primary" @click="priceChange(true)">{{$t('approval.adjust')}}</button>
  24. </view>
  25. </view>
  26. <view class="change-price-item">
  27. {{$t('approval.fixed')}}:
  28. <view class="inp">
  29. <u-input type="number" v-model="fixPrice" />
  30. </view>
  31. <view class="btn">
  32. <button class="oper-btn" type="primary" @click="priceChange(false)">{{$t('approval.adjust')}}</button>
  33. </view>
  34. </view>
  35. </view>
  36. </u-sticky>
  37. <template v-if="details.length">
  38. <view class="details-wrap">
  39. <p class="details-line details-title">
  40. <span v-if="priceType=='101'">{{$t('order.companyName')}}</span>
  41. <span v-if="priceType=='102'">{{$t('order.region')}}</span>
  42. <span>{{$t('order.materialName')}}</span>
  43. <span>{{$t('approval.latestPrice')}}</span>
  44. <span>{{$t('approval.adjustedPrice')}}</span>
  45. </p>
  46. <p v-for="(item,index) in details" :key="index" class="details-line">
  47. <span v-if="priceType=='101'">{{item.companyName}}</span>
  48. <span v-if="priceType=='102'">{{item.blockName}}</span>
  49. <span>{{item.materialName}}</span>
  50. <span>{{item.lastPrice || 0}}</span>
  51. <span>
  52. <u-input type="number" v-model="item.price" />
  53. </span>
  54. </p>
  55. </view>
  56. </template>
  57. <template v-else>
  58. <u-empty mode="list" text='请先选择调价信息' icon="https://cdn.uviewui.com/uview/empty/list.png">
  59. </u-empty>
  60. </template>
  61. <u-popup :show="showPicker" mode="center" zIndex="998" :overlay="false" @close="showView = false" >
  62. <view class="picker-card">
  63. <!-- 选择客户 -->
  64. <view class="choose-wrap">
  65. <view v-if="priceType == '101'" class="item">
  66. <view class="search-wrap">
  67. {{$t('approval.customerSelection')}}:
  68. </view>
  69. <view class="search-wrap">
  70. <u-input v-model="keyword" @change="getOptions" :placeholder="$t('base.search.keySearch')"/>
  71. </view>
  72. <u-checkbox-group
  73. v-model="clientIds"
  74. placement="column"
  75. >
  76. <u-checkbox
  77. :customStyle="{marginBottom: '8px'}"
  78. v-for="(item, index) in companyList"
  79. :key="index"
  80. :label="item.name"
  81. :name="item.id"
  82. >
  83. </u-checkbox>
  84. </u-checkbox-group>
  85. </view>
  86. <!-- 选择区域 -->
  87. <view v-if="priceType == '102'" class="item">
  88. <view class="search-wrap">
  89. {{$t('approval.regionalSelection')}}:
  90. </view>
  91. <view class="search-wrap">
  92. <u-input v-model="keyword" @change="getOptions" :placeholder="$t('base.search.keySearch')"/>
  93. </view>
  94. <u-checkbox-group
  95. v-model="blockIds"
  96. placement="column"
  97. >
  98. <u-checkbox
  99. :customStyle="{marginBottom: '8px'}"
  100. v-for="(item, index) in blockList"
  101. :key="index"
  102. :label="item.name"
  103. :name="item.id"
  104. >
  105. </u-checkbox>
  106. </u-checkbox-group>
  107. </view>
  108. <!-- 选择产品 -->
  109. <view class="item">
  110. <view class="search-wrap">
  111. {{$t('approval.productSelection')}}:
  112. </view>
  113. <view class="search-wrap">
  114. <u-input v-model="proKeyword" @change="getMater" :placeholder="$t('base.search.keySearch')"/>
  115. </view>
  116. <u-checkbox-group
  117. v-model="productIds"
  118. placement="column"
  119. >
  120. <u-checkbox
  121. :customStyle="{marginBottom: '8px'}"
  122. v-for="(item, index) in meterList"
  123. :key="index"
  124. :label="item.name"
  125. :name="item.id"
  126. >
  127. </u-checkbox>
  128. </u-checkbox-group>
  129. </view>
  130. </view>
  131. <view class="card-oper">
  132. <view class="btn">
  133. <button @click="showPicker = false">{{$t('settings.cancelText')}}</button>
  134. </view>
  135. <view class="btn">
  136. <button type='primary' @click="getPriceDetails">{{$t('settings.confirmText')}}</button>
  137. </view>
  138. </view>
  139. </view>
  140. </u-popup>
  141. </view>
  142. </template>
  143. <script>
  144. import {
  145. priceDetails
  146. } from "../../api/approval"
  147. import {
  148. getMater,
  149. getCompany,
  150. getBlock,
  151. } from "../../api/tenantorder"
  152. export default {
  153. data(){
  154. return {
  155. fixPrice:'',
  156. changePrice:null,
  157. showPicker:false,
  158. priceType:null,
  159. meterList:[], //产品选项列表
  160. companyList:[], //客户选项列表
  161. blockList:[], //区域选项列表
  162. details:[],
  163. keyword:'',
  164. proKeyword:'',
  165. clientIds:[], //选择的客户id
  166. blockIds:[], //选择的区域id
  167. productIds:[], //选择的产品
  168. }
  169. },
  170. onLoad(options) {
  171. this.priceType = options.priceType
  172. this.getMater()
  173. this.getOptions()
  174. },
  175. methods:{
  176. //确认调价
  177. sureChangePrice(){
  178. let pages = getCurrentPages();
  179. let prevPage = pages[pages.length - 2]; //上一个页面
  180. let details=[]
  181. this.details.forEach(item=>{
  182. if(this.priceType == '101'){
  183. details.push({
  184. companyId: item.companyId,
  185. companyName: item.companyName,
  186. lastPrice: item.lastPrice,
  187. price: item.price,
  188. materialId: item.materialId,
  189. materialName: item.materialName,
  190. })
  191. }else if(this.priceType == '102'){
  192. details.push({
  193. blockId: item.blockId,
  194. blockName: item.blockName,
  195. lastPrice: item.lastPrice,
  196. price: item.price,
  197. materialId: item.materialId,
  198. materialName: item.materialName,
  199. })
  200. }
  201. })
  202. prevPage.$vm.form.details = details;
  203. uni.navigateBack();
  204. },
  205. //获取客户/区域选项
  206. getOptions(){
  207. if(this.priceType == '101'){
  208. getCompany({type:'102'},this.keyword).then(res=>{
  209. if(res.data.code == 0){
  210. this.companyList = res.data.data
  211. }
  212. })
  213. }
  214. if(this.priceType == '102'){
  215. getBlock(this.keyword).then(res=>{
  216. if(res.data.code == 0){
  217. this.blockList = res.data.data
  218. }
  219. })
  220. }
  221. },
  222. //获取产品选项
  223. getMater(){
  224. getMater({type:"101"},this.proKeyword).then(res=>{
  225. if(res.data.code == 0){
  226. this.meterList=res.data.data
  227. }
  228. })
  229. },
  230. //调整价格
  231. priceChange(boo){
  232. if(boo){
  233. this.details.forEach(item=>{
  234. if(item.lastPrice){
  235. item.price = Number(item.lastPrice) + Number(this.changePrice)
  236. }else{
  237. item.price = Number(this.changePrice)
  238. }
  239. })
  240. }else{
  241. this.details.forEach(item=>{
  242. item.price = Number(this.fixPrice)
  243. })
  244. }
  245. },
  246. //获取产品价格详细
  247. getPriceDetails(){
  248. let data={}
  249. if(this.priceType == '101'){
  250. if(this.clientIds.length && this.productIds.length){
  251. data={
  252. companyIds:this.clientIds,
  253. materialIds:this.productIds,
  254. priceType:this.priceType,
  255. }
  256. priceDetails(data).then(res=>{
  257. if(res.data.code == 0){
  258. this.details = res.data.data
  259. this.showPicker = false
  260. }
  261. })
  262. }
  263. }else if(this.priceType == '102'){
  264. if(this.blockIds.length && this.productIds.length){
  265. data={
  266. blockIds:this.blockIds,
  267. materialIds:this.productIds,
  268. priceType:this.priceType,
  269. }
  270. priceDetails(data).then(res=>{
  271. if(res.data.code == 0){
  272. this.details = res.data.data
  273. this.showPicker = false
  274. }
  275. })
  276. }
  277. }
  278. },
  279. }
  280. }
  281. </script>
  282. <style lang="scss" scoped>
  283. /* #ifndef APP-NVUE */
  284. view {
  285. display: flex;
  286. box-sizing: border-box;
  287. flex-direction: column;
  288. }
  289. page {
  290. background-color: #f8f8f8;
  291. }
  292. /* #endif*/
  293. .price{
  294. /* #ifndef APP-NVUE */
  295. display: flex;
  296. width: 750rpx;
  297. min-height: 100vh;
  298. /* #endif */
  299. flex-direction: column;
  300. flex: 1;
  301. background-color: #f8f8f8;
  302. padding-bottom: 160rpx;
  303. .change-price-title{
  304. background-color: #fff;
  305. padding: 24rpx 32rpx;
  306. width: 100%;
  307. display: flex;
  308. .change-price-item{
  309. display: flex;
  310. flex-direction: row;
  311. align-items: center;
  312. margin-bottom: 24rpx;
  313. .btn{
  314. width: 20%;
  315. margin-left: 16rpx;
  316. .oper-btn{
  317. margin: 0;
  318. border-radius: 10rpx;
  319. }
  320. }
  321. .inp{
  322. margin-left: 16rpx;
  323. flex: 1;
  324. }
  325. }
  326. }
  327. .details-wrap{
  328. padding: 32rpx;
  329. background: #fff;
  330. margin-top: 24rpx;
  331. .details-line{
  332. display: flex;
  333. flex-direction: row;
  334. line-height: 40px;
  335. span{
  336. width: 25%;
  337. font-size: 28rpx;
  338. text-align: center;
  339. }
  340. }
  341. .details-title{
  342. span{
  343. font-weight: bold;
  344. }
  345. }
  346. .details-line:nth-child(odd){
  347. background-color: #f2f2f2;
  348. }
  349. .details-line:nth-child(even){
  350. background-color: #fff;
  351. }
  352. }
  353. .picker-btn{
  354. padding: 32rpx;
  355. position: fixed;
  356. bottom: 0;
  357. width: 100%;
  358. flex-direction: row;
  359. justify-content: space-between;
  360. background-color: #fff;
  361. z-index: 2;
  362. .btn{
  363. width: 48%;
  364. .oper-btn{
  365. margin: 0;
  366. }
  367. }
  368. }
  369. // padding: 32rpx;
  370. .picker-card{
  371. padding: 32rpx 32rpx 144rpx;
  372. position: relative;
  373. height: 100%;
  374. overflow-y: scroll;
  375. .choose-wrap{
  376. display: flex;
  377. flex-direction: row;
  378. justify-content: space-around;
  379. height: 100%;
  380. .item{
  381. width: 45%;
  382. height: 100%;
  383. overflow-y: scroll;
  384. .search-wrap{
  385. margin-bottom: 24rpx;
  386. }
  387. }
  388. }
  389. .card-oper{
  390. position: absolute;
  391. width: 100%;
  392. bottom: 0;
  393. left:0;
  394. display: flex;
  395. flex-direction: row;
  396. justify-content: space-between;
  397. padding: 24rpx;
  398. .btn{
  399. width: 45%;
  400. .oper-btn{
  401. margin: 0;
  402. }
  403. }
  404. }
  405. }
  406. }
  407. /deep/ .u-popup__content{
  408. height: 70%;
  409. overflow-y: scroll;
  410. width: 90%;
  411. border-radius: 6px;
  412. }
  413. </style>