selectCylinder.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <!-- 选择气瓶 -->
  2. <template>
  3. <view id="gasCylinderSelectCylinder">
  4. <view class="top-input-max-box">
  5. <view class="input-box">
  6. <uni-icons type="search" class="icon-box" color="#7C7C7C" size="25"></uni-icons>
  7. <input class="uni-input input-min" confirm-type="search" @confirm="getList()"
  8. v-model="inputData" maxlength="20" placeholder="搜索关键字" />
  9. <view class="button-p" @click="resetButton()">重置</view>
  10. </view>
  11. <view class="picker-box">
  12. <picker @change="bindPickerChangeA" :value="indexA" :range="arrayA">
  13. <view class="picker-min-box">
  14. <view>{{indexA==null?'气体':arrayA[indexA]}}</view>
  15. <uni-icons type="down" class="icon-box" size="15"></uni-icons>
  16. </view>
  17. </picker>
  18. <picker @change="bindPickerChangeB" :value="indexB" :range="arrayB">
  19. <view class="picker-min-box">
  20. <view>{{indexB==null?'气体类别':arrayB[indexB]}}</view>
  21. <uni-icons type="down" class="icon-box" size="15"></uni-icons>
  22. </view>
  23. </picker>
  24. </view>
  25. </view>
  26. <scroll-view scroll-y @scrolltolower="scrollGet" class="content-box">
  27. <view class="null-p" v-if="!dataList[0]">暂无数据</view>
  28. <view class="for-max-big-box" @click="checkButton(item)"
  29. v-for="(item,index) in dataList" :key="index">
  30. <view class="for-title-box" v-if="item.specialGases">
  31. <view>气瓶编码:</view>
  32. <view>{{item.bottleCode}}</view>
  33. </view>
  34. <view class="for-text-box">
  35. <view>气体:</view>
  36. <view>{{item.gasName}}</view>
  37. </view>
  38. <view class="for-text-box">
  39. <view>气瓶规格:</view>
  40. <view>{{item.specification}}</view>
  41. </view>
  42. <view class="for-text-box">
  43. <view>气体类别:</view>
  44. <view>{{item.gasCategory}}</view>
  45. </view>
  46. <view class="for-text-box" v-if="item.specialGases">
  47. <view>压力:</view>
  48. <view>{{item.pressure}}</view>
  49. </view>
  50. <view class="for-text-box">
  51. <view>纯度:</view>
  52. <view>{{item.purity}}</view>
  53. </view>
  54. </view>
  55. </scroll-view>
  56. <uni-icons class="sao-code-box" type="scan" color="#fff" size="25" @click="saoCode()"></uni-icons>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. airBottleNewQpAppletBottleScan,
  62. airbottleNewQpAppletBottlePage,airBottleNewQpDictList,
  63. } from '@/pages_supplierCylinderManagement/api/index.js'
  64. export default {
  65. data() {
  66. return {
  67. fromPage:'',
  68. inputData:'',
  69. arrayA:[],
  70. indexA:null,
  71. arrayB:[],
  72. indexB:null,
  73. dataList:[],
  74. // 查询参数
  75. getDataType: false,
  76. queryParams: {
  77. page: 1,
  78. pageSize: 10,
  79. },
  80. total:0,
  81. }
  82. },
  83. onLoad(options) {
  84. this.fromPage = options.from;
  85. },
  86. onShow() {
  87. this.airBottleNewQpDictList1();
  88. this.airBottleNewQpDictList2();
  89. this.getList();
  90. },
  91. methods: {
  92. bindPickerChangeA(e) {
  93. this.indexA = e.detail.value
  94. this.$set(this.queryParams,'page',1);
  95. this.getList();
  96. },
  97. bindPickerChangeB(e) {
  98. this.indexB = e.detail.value
  99. this.$set(this.queryParams,'page',1);
  100. this.getList();
  101. },
  102. //滚动加载事件
  103. scrollGet() {
  104. let self = this;
  105. if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
  106. this.$set(this, 'getDataType', true);
  107. } else {
  108. this.queryParams.page += 1;
  109. this.$nextTick(() => {
  110. this.getList();
  111. })
  112. }
  113. },
  114. //搜索
  115. async getList() {
  116. let self = this;
  117. let obj = {
  118. page:this.queryParams.page,
  119. pageSize:this.queryParams.pageSize,
  120. searchValue:this.inputData,
  121. gasName:this.indexA==null?'':this.arrayA[this.indexA],
  122. gasCategory:this.indexB==null?'':this.arrayB[this.indexB],
  123. };
  124. if(this.fromPage == 1){
  125. obj.state = 0;
  126. }else{
  127. obj.state = 1;
  128. }
  129. const {
  130. data
  131. } = await airbottleNewQpAppletBottlePage(obj);
  132. if (data.code == 200) {
  133. if(self.queryParams.page == 1){
  134. this.dataList = data.data.records;
  135. this.total = data.data.total;
  136. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  137. this.$set(this, 'getDataType', true);
  138. }
  139. }else{
  140. this.dataList = [...this.dataList, ...data.data.records]
  141. this.total = data.data.total;
  142. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  143. this.$set(this, 'getDataType', true);
  144. }
  145. }
  146. }
  147. },
  148. async airBottleNewQpDictList1() {
  149. const {
  150. data
  151. } = await airBottleNewQpDictList({"typeCode":'gas'});
  152. if (data.code == 200) {
  153. let list = [];
  154. for(let i=0;i<data.data.length;i++){
  155. list.push(data.data[i].name);
  156. }
  157. this.$set(this,'arrayA',list);
  158. }
  159. },
  160. async airBottleNewQpDictList2() {
  161. const {
  162. data
  163. } = await airBottleNewQpDictList({"typeCode":'gas_category'});
  164. if (data.code == 200) {
  165. let list = [];
  166. for(let i=0;i<data.data.length;i++){
  167. list.push(data.data[i].name);
  168. }
  169. this.$set(this,'arrayB',list);
  170. }
  171. },
  172. //重置
  173. resetButton(){
  174. this.$set(this,'inputData','');
  175. this.$set(this,'indexA',null);
  176. this.$set(this,'indexB',null);
  177. this.$set(this,'dataList',[]);
  178. this.$set(this,'getDataType',false);
  179. this.$set(this,'queryParams',{
  180. page: 1,
  181. pageSize: 10,
  182. });
  183. this.$set(this,'total',0);
  184. this.getList();
  185. },
  186. checkButton(item){
  187. let obj = {
  188. pageType:1,
  189. id:item.id,
  190. bottleCode:item.bottleCode,
  191. gasName:item.gasName,
  192. specification:item.specification,
  193. gasCategory:item.gasCategory,
  194. pressure:item.pressure,
  195. purity:item.purity,
  196. cost:item.cost,
  197. specialGases:item.specialGases,
  198. }
  199. uni.$emit('refreshBPageData', obj);
  200. uni.navigateBack({ delta: 1 });
  201. },
  202. /* 扫一扫*/
  203. saoCode() {
  204. let self = this;
  205. uni.scanCode({
  206. onlyFromCamera: true,
  207. success: function(res) {
  208. if(res.result.indexOf('type') != -1){
  209. let list = res.result.split("?")[1].split("&");
  210. let codeData = {};
  211. list.forEach((item) => {
  212. codeData[item.split("=")[0]] = item.split("=")[1];
  213. })
  214. if (codeData.type == 'gasCylinder' && codeData.code) {
  215. self.airBottleNewQpAppletBottleScan(codeData.code);
  216. }else{
  217. uni.showToast({
  218. title: '请扫描正确的二维码',
  219. icon: "error",
  220. mask: true,
  221. duration: 2000
  222. });
  223. }
  224. }else{
  225. uni.showToast({
  226. title: '请扫描正确的二维码',
  227. icon: "error",
  228. mask: true,
  229. duration: 2000
  230. });
  231. }
  232. }
  233. });
  234. },
  235. async airBottleNewQpAppletBottleScan(code) {
  236. const {
  237. data
  238. } = await airBottleNewQpAppletBottleScan({code:code});
  239. if (data.code == 200) {
  240. if(this.fromPage == 1 && data.data.state != 0){
  241. uni.showToast({
  242. title: '非待入库状态,无法入库',
  243. icon:"none",
  244. mask:true,
  245. duration: 3000
  246. });
  247. return
  248. }
  249. if(this.fromPage == 2 && data.data.state != 1){
  250. uni.showToast({
  251. title: '非使用中状态,无法出库',
  252. icon:"none",
  253. mask:true,
  254. duration: 3000
  255. });
  256. return
  257. }
  258. let obj = {
  259. pageType:1,
  260. id:data.data.id,
  261. bottleCode:data.data.bottleCode,
  262. gasName:data.data.gasName,
  263. specification:data.data.specification,
  264. gasCategory:data.data.gasCategory,
  265. pressure:data.data.pressure,
  266. purity:data.data.purity,
  267. specialGases:data.data.specialGases,
  268. }
  269. uni.$emit('refreshBPageData', obj);
  270. uni.navigateBack({ delta: 1 });
  271. }
  272. },
  273. }
  274. }
  275. </script>
  276. <style lang="stylus" scoped>
  277. #gasCylinderSelectCylinder {
  278. height: 100%;
  279. width: 100%;
  280. display flex ;
  281. flex-direction column;
  282. overflow: hidden;
  283. position: relative;
  284. .top-input-max-box{
  285. background-color: #fff;
  286. .input-box{
  287. display: flex;
  288. border-radius:40rpx;
  289. background-color: #eeeeee;
  290. margin:20rpx 20rpx 0 20rpx;
  291. color:#7C7C7C;
  292. .icon-box{
  293. margin:15rpx;
  294. }
  295. .input-min{
  296. height:80rpx;
  297. line-height:80rpx;
  298. flex:1;
  299. }
  300. .button-p{
  301. line-height:80rpx;
  302. width:120rpx;
  303. text-align: center;
  304. color:#333;
  305. font-size:28rpx;
  306. background-color: #D4D4D4;
  307. border-top-right-radius:40rpx;
  308. border-bottom-right-radius:40rpx;
  309. }
  310. }
  311. .picker-box{
  312. display: flex;
  313. .picker-min-box{
  314. height:80rpx;
  315. line-height:80rpx;
  316. display: flex;
  317. padding:0 30rpx;
  318. .icon-box{
  319. margin-left:10rpx;
  320. }
  321. }
  322. }
  323. }
  324. .content-box{
  325. flex:1;
  326. display flex ;
  327. flex-direction column;
  328. overflow: scroll;
  329. padding-bottom:40rpx;
  330. .null-p{
  331. text-align: center;
  332. line-height:300rpx;
  333. color:#999;
  334. }
  335. .for-max-big-box{
  336. padding:20rpx 30rpx;
  337. background-color: #fff;
  338. border-radius:10rpx;
  339. margin:25rpx 25rpx 0;
  340. .for-title-box{
  341. display: flex;
  342. margin-bottom:20rpx;
  343. view{
  344. padding-bottom:20rpx;
  345. line-height: 60rpx
  346. border-bottom:1rpx solid #dedede;
  347. font-weight:700;
  348. }
  349. view:nth-child(1){
  350. color:#666666;
  351. }
  352. view:nth-child(2){
  353. flex:1;
  354. text-align: right;
  355. }
  356. }
  357. .for-text-box{
  358. display: flex;
  359. view{
  360. line-height: 60rpx
  361. font-weight:700;
  362. }
  363. view:nth-child(1){
  364. color:#666666;
  365. }
  366. view:nth-child(2){
  367. flex:1;
  368. text-align: right;
  369. }
  370. }
  371. }
  372. }
  373. .sao-code-box{
  374. width:100rpx;
  375. height:100rpx;
  376. line-height:100rpx;
  377. text-align: center;
  378. background-color: #266FFF;
  379. border-radius:50%;
  380. position: absolute;
  381. bottom:60rpx;
  382. left:50%;
  383. margin-left:-50rpx;
  384. }
  385. }
  386. </style>