addCg.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <!--姜枫 2021.04.11-->
  2. <template>
  3. <view class="billing_box_bg">
  4. <view class="input-wrap" >
  5. <view class="search-bar">
  6. <app-search-module v-model="py" placeholder="输入拼音首字母搜索" @input="searchFn" />
  7. </view>
  8. <view style="float:right">
  9. <button class="admin-button-com middle blue" @click="removeFromSave(0)">清除花材</button>
  10. </view>
  11. </view>
  12. <view class="scroll-middle_bx">
  13. <scroll-view scroll-y scroll-with-animation class="tab-view">
  14. <div v-for="(item, index) in globalClassItemList" :key="index" class="tab-bar-item" :class="[classIndex == index ? 'active' : '']" :data-current="index" @tap.stop="swichClass(index)">
  15. <text>{{ item.className || "" }}</text>
  16. </div>
  17. <view style="height: 120upx"></view>
  18. </scroll-view>
  19. <scroll-view scroll-y class="right-box" :scroll-into-view="scroll_into_view"
  20. scroll-with-animation="true"
  21. @scroll="scroll_detail"
  22. lower-threshold="100"
  23. @scrolltolower="scroll_bottom">
  24. <block v-if="!$util.isEmpty(globalClassItemList)">
  25. <view class="item_list_bx selectAll" v-for="(classItem, classIndex) in globalClassItemList" :key="classIndex" :id="`class_${classIndex}`">
  26. <view class="item_list_title">
  27. {{ classItem.className }}
  28. </view>
  29. <template v-for="(productItem, productIndex) in classItem.child">
  30. <view style="height: 160upx" :id="`class_${classItem.classId}_${productItem.id}`" :key="productIndex">
  31. <Commondity v-if="classItem.isActive"
  32. :offVerifyRepertory = 'true'
  33. :info="productItem"
  34. :checkStock="true"
  35. :selectJobType="selectJobType"
  36. @showAddModelFn="showAddModelFn"
  37. @replaceItemFn="replaceItemFn"
  38. ></Commondity>
  39. </view>
  40. </template>
  41. </view>
  42. </block>
  43. <block v-else>
  44. <app-wrapper-empty title="加载中..." :is-empty="$util.isEmpty(globalClassItemList)" />
  45. </block>
  46. </scroll-view>
  47. </view>
  48. <modal-module :show="isAddModel" @cancel="addItemModelHidden" @click="confirmAddItemModel" :title="customData.name" color="#333" :size="32" padding="30rpx 30rpx">
  49. <template slot="customContent">
  50. <view class="select-cmd_bx" v-if="customData">
  51. <view class="kc">
  52. <text class="unit_price">库存 {{ parseFloat(customData.stock) }}</text>
  53. <text>{{customData.ratio}}{{customData.smallUnit}}/{{customData.bigUnit}}</text>
  54. </view>
  55. <view class="num_bx">
  56. <!-- #ifdef APP-PLUS -->
  57. <input style="width: 280upx" v-model="customData.bigCount" v-if="globalUnitType == 0" type="number" />
  58. <text style="font-size:35upx;font-weight:bold;color:#666666;" v-if="globalUnitType == 0">{{customData.bigUnit}}</text>
  59. <input style="width: 280upx" v-model="customData.smallCount" v-if="globalUnitType == 1" type="number" />
  60. <text style="font-size:35upx;font-weight:bold;color:#666666;" v-if="globalUnitType == 1">{{customData.smallUnit}}</text>
  61. <!-- #endif -->
  62. <!-- #ifdef MP-WEIXIN -->
  63. <input style="width: 280upx" v-model="customData.bigCount" v-if="globalUnitType == 0" :focus="isAddInputFocus" type="number" />
  64. <text style="font-size:35upx;font-weight:bold;color:#666666;" v-if="globalUnitType == 0">{{customData.bigUnit}}</text>
  65. <input style="width: 280upx" v-model="customData.smallCount" v-if="globalUnitType == 1" :focus="isAddInputFocus" type="number" />
  66. <text style="font-size:35upx;font-weight:bold;color:#666666;" v-if="globalUnitType == 1">{{customData.smallUnit}}</text>
  67. <!-- #endif -->
  68. <image @click="switchGlobalUnitType" :src="`${constant.imgUrl}/icon/switch/switch128.png`"
  69. style="width:86upx;height:86upx;position:relative;top:60upx;right:0upx;" mode="widthFix"></image>
  70. </view>
  71. <view class="num_bx">
  72. <input style="width: 280upx" v-model="customData.userPrice" @focus="customData.userPrice = null"
  73. :disabled="false" type="digit" placeholder="单价" />
  74. <text style="font-size:35upx;font-weight:bold;color:#666666;">元</text>
  75. </view>
  76. <view style="text-align:center;margin-bottom:30upx;font-size:33upx;">¥{{calcPrice}}</view>
  77. </view>
  78. </template>
  79. </modal-module>
  80. <FooterCart :price="allPrice" :count="allCount" @confirm="confirmSelectEvent"></FooterCart>
  81. <sel-popup :show="popupShow" :info="infoData" @close="hidePopup" />
  82. </view>
  83. </template>
  84. <script>
  85. import AppSearchModule from "@/components/module/app-search";
  86. import AppTabs from "@/components/plugin/tabs";
  87. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  88. import Commondity from "@/components/module/app-cg-commodity";
  89. import FooterCart from "@/components/module/app-footer-cart";
  90. import ModalModule from "@/components/plugin/modal";
  91. import SelPopup from "@/components/sel-popup.vue";
  92. import { COMMODITY_TYPE } from "@/utils/declare";
  93. import productMins from "@/mixins/product";
  94. export default {
  95. name: "addCg",
  96. components: {
  97. AppTabs,
  98. AppSearchModule,
  99. AppWrapperEmpty,
  100. Commondity,
  101. ModalModule,
  102. FooterCart,
  103. SelPopup
  104. },
  105. mixins: [productMins],
  106. data() {
  107. return {
  108. COMMODITY_TYPE,
  109. isSmallCount:false,
  110. isFocus: false,
  111. offVerifyRepertory: true,
  112. customData: {
  113. bigCount: 0,
  114. smallCount: 0
  115. },
  116. showSubmitModel: false,
  117. popupShow:false,
  118. infoData:{},
  119. selectJobType:'cgItem',
  120. checkStock:false
  121. };
  122. },
  123. computed: {
  124. calcPrice() {
  125. if(Number(this.customData.userPrice)>0 && (Number(this.customData.bigCount)>0 || Number(this.customData.smallCount)>0)){
  126. let num = Number(this.customData.bigCount)>0 ? this.customData.bigCount : this.customData.smallCount
  127. return parseFloat((this.customData.userPrice*num).toFixed(2))
  128. }
  129. return 0
  130. }
  131. },
  132. onLoad(){
  133. if(this.option.ghsId){
  134. this.selectJobId = this.option.ghsId
  135. }
  136. this.initData()
  137. },
  138. methods: {
  139. showPopup() {
  140. this.popupShow = true;
  141. },
  142. hidePopup() {
  143. this.popupShow = false;
  144. },
  145. modalCancel() {
  146. this.isAddModel = false;
  147. this.customData = {};
  148. },
  149. cancelEvent() {
  150. this.showSubmitModel = false;
  151. },
  152. submitEvent(val) {
  153. if (val.index === 0) {
  154. this.cancelEvent();
  155. } else {
  156. console.log(444, this.selectList);
  157. uni.navigateTo({
  158. url: "/admin/billing/affirm"
  159. });
  160. this.cancelEvent();
  161. }
  162. },
  163. confirmSelectGoodsEvent() {
  164. if (this.selectList.length > 0) {
  165. uni.navigateTo({
  166. url: "/admin/billing/affirmGoods"
  167. });
  168. } else {
  169. this.$msg("请选择花材");
  170. }
  171. },
  172. confirmSelectEvent() {
  173. if(this.$util.isEmpty(this.selectList)){
  174. this.$msg('请选择花材')
  175. return false
  176. }
  177. //因历史遗留原因,打开花材页马上点花材出现数量0或null的情况,需要过滤 shish 20210716
  178. let selectList = this.selectList;
  179. let list = [];
  180. for (let i=0;i<selectList.length;i++){
  181. if(/(^[1-9]\d*$)/.test(selectList[i].bigCount) == false && /(^[1-9]\d*$)/.test(selectList[i].smallCount) == false){
  182. continue
  183. }
  184. list.push(selectList[i])
  185. }
  186. if(list.length <= 0){
  187. this.$msg("请选择花材")
  188. return
  189. }
  190. let ghsName = this.option.ghsName ? this.option.ghsName : '';
  191. let ghsId = this.option.ghsId ? this.option.ghsId : 0
  192. this.$util.pageTo({ url: '/pagesPurchase/addCgConfirm?ghsId='+ghsId+'&ghsName='+ghsName,type:2})
  193. }
  194. }
  195. };
  196. </script>
  197. <style lang="scss" scoped>
  198. .billing_box_bg {
  199. height: 100%;
  200. display: flex;
  201. flex-direction: column;
  202. .input-wrap {
  203. padding: 22upx 20upx 22upx 30upx;
  204. .search-bar {
  205. display:inline-block;
  206. width:530upx;
  207. }
  208. }
  209. .scroll-middle_bx {
  210. flex: 1;
  211. display: flex;
  212. width: 100%;
  213. height: 100%;
  214. overflow: hidden;
  215. }
  216. .tab-view {
  217. height: calc(100vh - 140upx);
  218. width: 170upx;
  219. flex-shrink: 0;
  220. background-color: #f0f2f6;
  221. .tab-bar-item {
  222. position: relative;
  223. width: 170upx;
  224. height: 90upx;
  225. box-sizing: border-box;
  226. display: flex;
  227. align-items: center;
  228. justify-content: center;
  229. font-size: 26upx;
  230. color: #444;
  231. font-weight: 400;
  232. .tag {
  233. display: flex;
  234. padding: 0 20upx;
  235. align-items: center;
  236. position: absolute;
  237. right: 0;
  238. top: 0;
  239. height: 32upx;
  240. background: #ff2842;
  241. border-radius: 16upx;
  242. color: #fff;
  243. font-size: 20upx;
  244. }
  245. &:last-child{
  246. margin-bottom: 110upx;
  247. }
  248. }
  249. .active {
  250. position: relative;
  251. color: $mainColor;
  252. font-size: 26upx;
  253. background: #fff;
  254. }
  255. .active::before {
  256. content: "";
  257. position: absolute;
  258. border-left: 8upx solid $mainColor;
  259. height: 100%;
  260. left: 0;
  261. }
  262. }
  263. .right-box {
  264. height: calc(100vh - 140upx);
  265. flex: 1;
  266. box-sizing: border-box;
  267. }
  268. .item_list_bx {
  269. padding: 40upx 16upx;
  270. &:last-child{
  271. margin-bottom: 70upx;
  272. }
  273. }
  274. .item_list_title {
  275. margin-bottom: 20upx;
  276. font-size: 24upx;
  277. font-weight: 600;
  278. color: #666666;
  279. }
  280. .select-cmd_bx {
  281. & .kc {
  282. color: #999999;
  283. font-size: 28upx;
  284. font-weight: 400;
  285. margin-bottom: 40upx;
  286. text-align: center;
  287. margin-top: 30upx;
  288. .unit_price{
  289. padding-right:25upx;
  290. }
  291. }
  292. & .num_bx {
  293. display: flex;
  294. align-items: center;
  295. margin-bottom:30upx;
  296. padding-left:110upx;
  297. & > input {
  298. width: 212upx;
  299. height: 80upx;
  300. border: 1upx solid #dddddd;
  301. border-radius: 4upx;
  302. text-align: center;
  303. margin-right: 24upx;
  304. font-size: 40upx;
  305. }
  306. }
  307. }
  308. .PxClass-box{
  309. width: 100%;
  310. }
  311. }
  312. </style>