ConsumableList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. <template>
  2. <div class="bgColor">
  3. <div slot="content" class="scroll-wrapper">
  4. <div class="demo">
  5. <div class="header">耗材列表</div>
  6. <div class="seatchHeader">
  7. <div class="search fl">
  8. <input
  9. class="searchInp"
  10. type="text"
  11. v-model="title"
  12. placeholder="可通过名称、型号品牌进行检索支持拼音"
  13. @input="searchData()"
  14. />
  15. </div>
  16. <!-- <button class="selectBtn fr" @click="showPicker">筛选</button> -->
  17. </div>
  18. <div class="scroll-list-wrap">
  19. <cube-scroll
  20. ref="scroll"
  21. :data="items"
  22. :options="options"
  23. @pulling-down="onPullingDown"
  24. @pulling-up="onPullingUp"
  25. >
  26. <div class="conentBox">
  27. <div
  28. class="conent"
  29. v-for="(item, index) in items"
  30. @click="showModal(item)"
  31. :key="index"
  32. >
  33. <div class="head">
  34. <p>
  35. <span>{{ item.name }}</span>
  36. <span>{{ item.brandModel }}</span>
  37. </p>
  38. </div>
  39. <div class="center">
  40. <p>
  41. <span class="fl"></span>
  42. <span class="grayFont overflowEllipsis2">{{item.endPrice}}元</span>
  43. </p>
  44. </div>
  45. </div>
  46. <div class="wushuju" v-show="wushuju">
  47. <img src="./../../static/images/wushuju.svg" alt />
  48. <p>暂无数据</p>
  49. </div>
  50. </div>
  51. <template v-if="customPullDown" slot="pulldown" slot-scope="props">
  52. <div
  53. v-if="props.pullDownRefresh"
  54. class="cube-pulldown-wrapper"
  55. :style="props.pullDownStyle"
  56. >
  57. <div
  58. v-show="props.beforePullDown"
  59. class="before-trigger"
  60. :style="{ paddingTop: props.bubbleY + 'px' }"
  61. >
  62. <span
  63. :class="{
  64. rotate: props.bubbleY > pullDownRefreshThreshold - 40
  65. }"
  66. >↓</span
  67. >
  68. </div>
  69. <div class="after-trigger" v-show="!props.beforePullDown">
  70. <div v-show="props.isPullingDown" class="loading">
  71. <cube-loading></cube-loading>
  72. </div>
  73. <div v-show="!props.isPullingDown" class="text">
  74. <span class="refresh-text">更新成功</span>
  75. </div>
  76. </div>
  77. </div>
  78. </template>
  79. </cube-scroll>
  80. </div>
  81. </div>
  82. </div>
  83. <load-ing v-if="!items.length && !wushuju"></load-ing>
  84. <!-- 弹窗 -->
  85. <showModel
  86. v-if="models.disjunctor"
  87. :title="models.title"
  88. :icon="models.icon"
  89. :disjunctor="models.disjunctor"
  90. @ok="ok"
  91. @cancel="cancel"
  92. :operate="models.operate"
  93. selectName="hc_add"
  94. :data="hcData"
  95. ></showModel>
  96. </div>
  97. </template>
  98. <script>
  99. import Vue from "vue";
  100. import showModel from "../components/showModel/showModel.vue";
  101. import CubePage from "../components/cube-page.vue";
  102. import SwitchOption from "../components/switch-option";
  103. import InputOption from "../components/input-option";
  104. import SelectOption from "../components/select-option";
  105. import LoadIng from "./loading.vue";
  106. export default {
  107. data() {
  108. return {
  109. hcData: {},
  110. modelsData: {}, //点击弹窗的那一项数据
  111. // 弹窗model
  112. models: {
  113. disjunctor: false
  114. },
  115. valConfig: JSON.parse(localStorage.getItem("valConfig")) - 0, //报修主体
  116. items: [],
  117. pullDownRefresh: true,
  118. pullDownRefreshThreshold: 60,
  119. pullDownRefreshStop: 40,
  120. pullDownRefreshTxt: "Refresh success",
  121. pullUpLoad: true,
  122. pullUpLoadThreshold: 0,
  123. pullUpLoadMoreTxt: "加载更多",
  124. pullUpLoadNoMoreTxt: "没有更多数据",
  125. customPullDown: true,
  126. wushuju: false,
  127. title: "", //搜索内容
  128. // stateData: [
  129. // {
  130. // text: "全部",
  131. // value: "all"
  132. // },
  133. // {
  134. // text: "待处理",
  135. // value: "todo"
  136. // },
  137. // {
  138. // text: "处理过",
  139. // value: "done"
  140. // }
  141. // ],
  142. // stateValue: "todo",
  143. sum: 20,
  144. idx: 0,
  145. stateClass: "",
  146. loadShow: true,
  147. searching: false
  148. };
  149. },
  150. components: {
  151. CubePage,
  152. SwitchOption,
  153. InputOption,
  154. SelectOption,
  155. LoadIng,
  156. showModel,
  157. },
  158. computed: {
  159. options() {
  160. return {
  161. pullDownRefresh: this.pullDownRefreshObj,
  162. pullUpLoad: this.pullUpLoadObj,
  163. scrollbar: true
  164. };
  165. },
  166. pullDownRefreshObj: function() {
  167. return this.pullDownRefresh
  168. ? {
  169. threshold: parseInt(this.pullDownRefreshThreshold),
  170. txt: this.pullDownRefreshTxt
  171. }
  172. : false;
  173. },
  174. pullUpLoadObj: function() {
  175. return this.pullUpLoad
  176. ? {
  177. threshold: parseInt(this.pullUpLoadThreshold),
  178. txt: {
  179. more: this.pullUpLoadMoreTxt,
  180. noMore: this.pullUpLoadNoMoreTxt
  181. }
  182. }
  183. : false;
  184. }
  185. },
  186. methods: {
  187. //确定
  188. ok(data) {
  189. console.log(data);
  190. const reg = /(^[1-9][0-9]*$)/;
  191. if(!reg.test(data.consumablesNum)){
  192. this.$createDialog({
  193. type: "alert",
  194. title: "请输入大于0的正整数!",
  195. icon: "cubeic-warn"
  196. }).show();
  197. return;
  198. }
  199. const toast = this.$createToast({
  200. txt: "Loading...",
  201. mask: true
  202. });
  203. toast.show();
  204. this.$http
  205. .post("service/bpm/data/addSummaryDoc", {
  206. "consumableList": [
  207. {
  208. "consumablesId": data.hc.id,
  209. "consumablesNum": data.consumablesNum
  210. }
  211. ],
  212. "summaryId": this.$route.params.summaryId
  213. })
  214. .then(res => {
  215. toast.hide();
  216. this.models.disjunctor = false;
  217. if (res.data.status == 200) {
  218. this.$createDialog({
  219. type: "alert",
  220. title: "操作成功",
  221. icon: "cubeic-right",
  222. onConfirm: (e, promptValue) => {
  223. this.loadShow = false;
  224. this.items = [];
  225. this.idx = 0;
  226. this.$router.push({
  227. path: `/summaryOrder/${this.$route.params.incidentId}/${this.$route.params.processInstanceId}`
  228. })
  229. }
  230. }).show();
  231. } else {
  232. this.$createDialog({
  233. type: "alert",
  234. title: "系统错误,请稍后再试!",
  235. icon: "cubeic-wrong",
  236. onConfirm: (e, promptValue) => {
  237. this.loadShow = false;
  238. this.items = [];
  239. this.idx = 0;
  240. this.$router.push({
  241. path: `/summaryOrder/${this.$route.params.incidentId}/${this.$route.params.processInstanceId}`
  242. })
  243. }
  244. }).show();
  245. }
  246. });
  247. },
  248. //取消
  249. cancel() {
  250. this.models.disjunctor = false;
  251. },
  252. // 弹窗
  253. showModal(item) {
  254. this.modelsData = item;
  255. this.hcData = {
  256. hc: item,
  257. incidentId: this.$route.params.incidentId,
  258. summaryId: this.$route.params.summaryId,
  259. }
  260. this.models = {
  261. disjunctor: true,
  262. title: "提示",
  263. icon: "warn",
  264. operate: {
  265. ok: "确定",
  266. cancel: "取消"
  267. }
  268. };
  269. },
  270. getParamsState() {
  271. console.log(this.$route.params.state)
  272. if (this.$route.params.state) {
  273. console.log(this.$route.params.state);
  274. this.stateValue = this.$route.params.state;
  275. }
  276. },
  277. showPicker() {
  278. if (!this.picker) {
  279. this.picker = this.$createPicker({
  280. title: "",
  281. data: [this.stateData],
  282. selectedIndex: [1],
  283. onSelect: this.selectHandle,
  284. onCancel: this.cancelHandle
  285. });
  286. }
  287. this.picker.show();
  288. },
  289. selectHandle(selectedVal, selectedIndex, selectedText) {
  290. console.log(selectedVal, selectedIndex, selectedText);
  291. this.stateValue = selectedVal[0];
  292. this.items = [];
  293. this.getData();
  294. },
  295. cancelHandle() {},
  296. // 搜索
  297. searchData() {
  298. this.items = [];
  299. this.searching = true;
  300. this.getData();
  301. },
  302. // 获取列表
  303. getData() {
  304. console.log(this.stateValue);
  305. if (this.searching) {
  306. this.idx = 0;
  307. }
  308. let title = this.title;
  309. let postData = {
  310. idx: this.idx,
  311. sum: this.sum,
  312. consumable: {
  313. keyWord: this.title || '',
  314. }
  315. };
  316. this.$http
  317. .post(
  318. "service/bpm/data/fetchDataList/consumable",
  319. postData
  320. )
  321. .then((res) => {
  322. if(res.status == 200){
  323. if(title == this.title){
  324. if (res.data.list.length > 0) {
  325. this.wushuju = false;
  326. if (this.searching) {
  327. this.items = res.data.list;
  328. } else {
  329. this.items = this.items.concat(res.data.list);
  330. }
  331. } else {
  332. this.wushuju = this.searching;
  333. }
  334. }
  335. }else{
  336. this.$createDialog({
  337. type: "alert",
  338. title: "操作失败",
  339. content: "请求失败!",
  340. icon: "cubeic-wrong"
  341. }).show();
  342. }
  343. this.loadShow = false;
  344. });
  345. },
  346. onPullingDown() {
  347. // 模拟更新数据
  348. var that = this;
  349. that.items = [];
  350. that.idx = 0;
  351. that.searching = false;
  352. setTimeout(() => {
  353. that.getData();
  354. }, 1000);
  355. },
  356. onPullingUp() {
  357. var that = this;
  358. that.idx = that.idx + 1;
  359. that.searching = false;
  360. that.getData();
  361. },
  362. updatePullDownRefresh(val) {
  363. this.pullDownRefresh = val;
  364. },
  365. updatePullDownRefreshThreshold(val) {
  366. this.pullDownRefreshThreshold = val;
  367. },
  368. updatePullDownRefreshTxt(val) {
  369. this.pullDownRefreshTxt = val;
  370. },
  371. updatePullUpLoad(val) {
  372. this.pullUpLoad = val;
  373. },
  374. updatePullUpLoadThreshold(val) {
  375. this.pullUpLoadThreshold = val;
  376. },
  377. updatePullUpLoadMoreTxt(val) {
  378. this.pullUpLoadMoreTxt = val;
  379. },
  380. updatePullUpLoadNoMoreTxt(val) {
  381. this.pullUpLoadNoMoreTxt = val;
  382. },
  383. updateCustomPullDown(val) {
  384. this.customPullDown = val;
  385. },
  386. rebuildScroll() {
  387. Vue.nextTick(() => {
  388. this.$refs.scroll.destroy();
  389. this.$refs.scroll.initScroll();
  390. });
  391. }
  392. },
  393. created() {
  394. // this.$route.params.data
  395. // this.getParamsState();
  396. this.getData(this.idx, this.sum);
  397. }
  398. };
  399. </script>
  400. <style lang="stylus" rel="stylesheet/stylus" scoped>
  401. .scroll-list-wrap {
  402. /* height: 350px */
  403. height: 90vh;
  404. /* border: 1px solid rgba(0, 0, 0, 0.1) */
  405. border-radius: 5px;
  406. transform: rotate(0deg); // fix 子元素超出边框圆角部分不隐藏的问题
  407. // overflow: hidden;
  408. padding-top: 1.76rem;
  409. }
  410. .foods-wrapper {
  411. .food-item {
  412. display: flex;
  413. /* padding: 18px */
  414. /* border-bottom: 1px solid rgba(7, 17, 27, 0.1) */
  415. /* border-top: 1px solid rgba(7, 17, 27, 0.1)!important */
  416. &:last-child {
  417. border-none();
  418. margin-bottom: 0;
  419. }
  420. .icon {
  421. flex: 0 0 57px;
  422. margin-right: 10px;
  423. }
  424. .food-content {
  425. flex: 1;
  426. .name {
  427. margin: 2px 0 8px 0;
  428. height: 14px;
  429. line-height: 14px;
  430. font-size: 14px;
  431. color: rgb(7, 17, 27);
  432. }
  433. .description, .extra {
  434. line-height: 10px;
  435. font-size: 10px;
  436. color: rgb(147, 153, 159);
  437. }
  438. .description {
  439. line-height: 12px;
  440. margin-bottom: 8px;
  441. }
  442. .extra {
  443. .count {
  444. margin-right: 12px;
  445. }
  446. }
  447. .price {
  448. font-weight: 700;
  449. line-height: 24px;
  450. .now {
  451. margin-right: 8px;
  452. font-size: 14px;
  453. color: rgb(240, 20, 20);
  454. }
  455. .old {
  456. text-decoration: line-through;
  457. font-size: 10px;
  458. color: rgb(147, 153, 159);
  459. }
  460. }
  461. .cartcontrol-wrapper {
  462. position: absolute;
  463. right: 0;
  464. bottom: 12px;
  465. .scroll-wrapper {
  466. .cube-pulldown-wrapper {
  467. .before-trigger {
  468. font-size: 30px;
  469. line-height: 30px;
  470. align-self: flex-end;
  471. span {
  472. display: inline-block;
  473. transition: all 0.3s;
  474. color: #666;
  475. &.rotate {
  476. transform: rotate(180deg);
  477. }
  478. }
  479. }
  480. .after-trigger {
  481. .refresh-text {
  482. color: grey;
  483. }
  484. }
  485. }
  486. }
  487. }
  488. }
  489. }
  490. }
  491. </style>
  492. <style lang="less" scoped>
  493. .bgColor {
  494. background-color: white;
  495. }
  496. .food-item {
  497. border-top: 0.16rem rgb(238, 238, 238) solid;
  498. }
  499. .food-content {
  500. border-top: 0.01rem rgb(223, 222, 222) solid;
  501. border-bottom: 0.01rem rgb(223, 222, 222) solid;
  502. }
  503. .title {
  504. display: flex;
  505. justify-content: space-between;
  506. height: 0.7rem;
  507. line-height: 0.7rem;
  508. border-top: 0.01rem rgb(223, 222, 222) solid;
  509. padding: 0 0.24rem;
  510. border-bottom: 0.01rem rgb(223, 222, 222) solid;
  511. }
  512. .title i {
  513. font-size: 0.32rem;
  514. color: #005395;
  515. }
  516. .title div:nth-child(1) {
  517. font-size: 0.32rem;
  518. }
  519. .title div:nth-child(1) span {
  520. display: inline-block;
  521. margin-left: 0.08rem;
  522. }
  523. .title div:nth-child(2) {
  524. padding: 0.05rem 0.3rem;
  525. /* border: 0.01rem rgb(0,0,255) solid; */
  526. border-radius: 16px;
  527. /* color: rgb(0,0,255); */
  528. height: 0.25rem;
  529. line-height: 0.25rem;
  530. margin-top: 0.15rem;
  531. font-size: 0.24rem;
  532. }
  533. .weishouli {
  534. color: #991f00;
  535. border: 0.01rem #991f00 solid;
  536. background-color: #f4e8e5;
  537. }
  538. .bushouli {
  539. color: #666666;
  540. background-color: #eeeeee;
  541. border: 0.01rem #666666 solid;
  542. }
  543. .chulizhong {
  544. color: #003057;
  545. background-color: #e5eaee;
  546. border: 0.01rem #003057 solid;
  547. }
  548. .daipingjia {
  549. color: #825b00;
  550. background-color: #f2eee5;
  551. border: 0.01rem #825b00 solid;
  552. }
  553. .yijiejue {
  554. color: #40a19c;
  555. background-color: #ebf5f5;
  556. border: 0.01rem #40a19c solid;
  557. }
  558. .yichehui {
  559. color: #48a843;
  560. background-color: #ecf6ec;
  561. border: 0.01rem #48a843 solid;
  562. }
  563. .timeBox {
  564. display: flex;
  565. justify-content: space-between;
  566. font-size: 0.24rem;
  567. color: #999999;
  568. border-top: 0.01rem rgb(223, 222, 222) solid;
  569. height: 0.7rem;
  570. line-height: 0.7rem;
  571. padding: 0 0.24rem 0 0.64rem;
  572. }
  573. .wushuju {
  574. margin-top: 2.4rem;
  575. text-align: center;
  576. color: #999;
  577. }
  578. .wushuju img {
  579. width: 5.12rem;
  580. height: 2.84rem;
  581. }
  582. .demo {
  583. .header {
  584. width: 100%;
  585. height: 0.88rem;
  586. line-height: 0.88rem;
  587. text-align: center;
  588. color: #fff;
  589. font-size: 0.37rem;
  590. background: linear-gradient(#2e2f32, #414246);
  591. position: fixed;
  592. top: 0;
  593. z-index: 6;
  594. }
  595. .seatchHeader {
  596. width: 100%;
  597. background-color: #eee;
  598. padding: 0.16rem;
  599. overflow: hidden;
  600. position: fixed;
  601. top: 0.88rem;
  602. z-index: 6;
  603. box-sizing: border-box;
  604. .search {
  605. width: 100%;
  606. height: 0.56rem;
  607. font-size: 0.26rem;
  608. color: #b2b2b2;
  609. box-sizing: border-box;
  610. .searchInp {
  611. text-align: center;
  612. background-color: #fff;
  613. width: 100%;
  614. height: 100%;
  615. border-radius: 0.09rem;
  616. border: none;
  617. &:focus {
  618. outline: none;
  619. }
  620. }
  621. }
  622. .selectBtn {
  623. width: 1.2rem;
  624. height: 0.56rem;
  625. font-size: 0.32rem;
  626. color: #005395;
  627. border-color: #005395;
  628. background-color: #fff;
  629. border-radius: 0.09rem;
  630. &:focus {
  631. outline: none;
  632. }
  633. }
  634. }
  635. }
  636. .conentBox {
  637. width: 100%;
  638. .conent {
  639. font-size: 0.32rem;
  640. font-weight: 400;
  641. line-height: 0.45rem;
  642. border-bottom: 0.16rem solid #e5e5e5;
  643. .head {
  644. border-bottom: 0.01rem solid #e6e6e6;
  645. p {
  646. padding: 0.24rem 0.48rem;
  647. display: flex;
  648. justify-content: space-between;
  649. align-items: center;
  650. i {
  651. color: #00559d;
  652. }
  653. .btn {
  654. float: right;
  655. }
  656. }
  657. }
  658. .center {
  659. color: #333333;
  660. border-bottom: 0.01rem solid #e6e6e6;
  661. padding: 0.24rem 0.48rem;
  662. p {
  663. display: flex;
  664. justify-content: space-between;
  665. align-items: center;
  666. .grayFont {
  667. color: #666;
  668. }
  669. }
  670. }
  671. .bottom {
  672. overflow: hidden;
  673. line-height: 0.86rem;
  674. border-bottom: 0.01rem solid #e6e6e6;
  675. font-size: 0.24rem;
  676. color: #999;
  677. padding: 0 0.24rem 0 0.48rem;
  678. }
  679. }
  680. }
  681. </style>