selectCylinder.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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. specialGases:item.specialGases,
  197. }
  198. uni.$emit('refreshBPageData', obj);
  199. uni.navigateBack({ delta: 1 });
  200. },
  201. /* 扫一扫*/
  202. saoCode() {
  203. let self = this;
  204. uni.scanCode({
  205. onlyFromCamera: true,
  206. success: function(res) {
  207. if(res.result.indexOf('type') != -1){
  208. let list = res.result.split("?")[1].split("&");
  209. let codeData = {};
  210. list.forEach((item) => {
  211. codeData[item.split("=")[0]] = item.split("=")[1];
  212. })
  213. if (codeData.type == 'gasCylinder' && codeData.code) {
  214. self.airBottleNewQpAppletBottleScan(codeData.code);
  215. }else{
  216. uni.showToast({
  217. title: '请扫描正确的二维码',
  218. icon: "error",
  219. mask: true,
  220. duration: 2000
  221. });
  222. }
  223. }else{
  224. uni.showToast({
  225. title: '请扫描正确的二维码',
  226. icon: "error",
  227. mask: true,
  228. duration: 2000
  229. });
  230. }
  231. }
  232. });
  233. },
  234. async airBottleNewQpAppletBottleScan(code) {
  235. const {
  236. data
  237. } = await airBottleNewQpAppletBottleScan({code:code});
  238. if (data.code == 200) {
  239. if(this.fromPage == 1 && data.data.state != 0){
  240. uni.showToast({
  241. title: '非待入库状态,无法入库',
  242. icon:"none",
  243. mask:true,
  244. duration: 3000
  245. });
  246. return
  247. }
  248. if(this.fromPage == 2 && data.data.state != 1){
  249. uni.showToast({
  250. title: '非使用中状态,无法出库',
  251. icon:"none",
  252. mask:true,
  253. duration: 3000
  254. });
  255. return
  256. }
  257. let obj = {
  258. pageType:1,
  259. id:data.data.id,
  260. bottleCode:data.data.bottleCode,
  261. gasName:data.data.gasName,
  262. specification:data.data.specification,
  263. gasCategory:data.data.gasCategory,
  264. pressure:data.data.pressure,
  265. purity:data.data.purity,
  266. specialGases:data.data.specialGases,
  267. }
  268. uni.$emit('refreshBPageData', obj);
  269. uni.navigateBack({ delta: 1 });
  270. }
  271. },
  272. }
  273. }
  274. </script>
  275. <style lang="stylus" scoped>
  276. #gasCylinderSelectCylinder {
  277. height: 100%;
  278. width: 100%;
  279. display flex ;
  280. flex-direction column;
  281. overflow: hidden;
  282. position: relative;
  283. .top-input-max-box{
  284. background-color: #fff;
  285. .input-box{
  286. display: flex;
  287. border-radius:40rpx;
  288. background-color: #eeeeee;
  289. margin:20rpx 20rpx 0 20rpx;
  290. color:#7C7C7C;
  291. .icon-box{
  292. margin:15rpx;
  293. }
  294. .input-min{
  295. height:80rpx;
  296. line-height:80rpx;
  297. flex:1;
  298. }
  299. .button-p{
  300. line-height:80rpx;
  301. width:120rpx;
  302. text-align: center;
  303. color:#333;
  304. font-size:28rpx;
  305. background-color: #D4D4D4;
  306. border-top-right-radius:40rpx;
  307. border-bottom-right-radius:40rpx;
  308. }
  309. }
  310. .picker-box{
  311. display: flex;
  312. .picker-min-box{
  313. height:80rpx;
  314. line-height:80rpx;
  315. display: flex;
  316. padding:0 30rpx;
  317. .icon-box{
  318. margin-left:10rpx;
  319. }
  320. }
  321. }
  322. }
  323. .content-box{
  324. flex:1;
  325. display flex ;
  326. flex-direction column;
  327. overflow: scroll;
  328. padding-bottom:40rpx;
  329. .null-p{
  330. text-align: center;
  331. line-height:300rpx;
  332. color:#999;
  333. }
  334. .for-max-big-box{
  335. padding:20rpx 30rpx;
  336. background-color: #fff;
  337. border-radius:10rpx;
  338. margin:25rpx 25rpx 0;
  339. .for-title-box{
  340. display: flex;
  341. margin-bottom:20rpx;
  342. view{
  343. padding-bottom:20rpx;
  344. line-height: 60rpx
  345. border-bottom:1rpx solid #dedede;
  346. font-weight:700;
  347. }
  348. view:nth-child(1){
  349. color:#666666;
  350. }
  351. view:nth-child(2){
  352. flex:1;
  353. text-align: right;
  354. }
  355. }
  356. .for-text-box{
  357. display: flex;
  358. view{
  359. line-height: 60rpx
  360. font-weight:700;
  361. }
  362. view:nth-child(1){
  363. color:#666666;
  364. }
  365. view:nth-child(2){
  366. flex:1;
  367. text-align: right;
  368. }
  369. }
  370. }
  371. }
  372. .sao-code-box{
  373. width:100rpx;
  374. height:100rpx;
  375. line-height:100rpx;
  376. text-align: center;
  377. background-color: #266FFF;
  378. border-radius:50%;
  379. position: absolute;
  380. bottom:60rpx;
  381. left:50%;
  382. margin-left:-50rpx;
  383. }
  384. }
  385. </style>