but.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="but-box" v-if="text">
  3. <view style="width: 75vw;">
  4. <u-button type="primary" :text="text" color="rgba(42,106,242,.8)" loadingText="执行中..." :loading="loading"
  5. @click="onClick(false)" />
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: "but",
  12. props: {
  13. sa_workorderid: {
  14. type: [String, Number],
  15. default: 0
  16. },
  17. status: {
  18. type: String
  19. },
  20. onUpdate: {
  21. type: Function
  22. },
  23. unShowBut: {
  24. type: Function
  25. }
  26. },
  27. watch: {
  28. status: function (newVal) {
  29. this.loading = false;
  30. this.$emit("unShowBut", true)
  31. switch (newVal) {
  32. case '待接单':
  33. this.text = '接单';
  34. this.id = 20230210101103;
  35. this.tips = '是否确定接收工单';
  36. this.toast = '工单接单成功!';
  37. break;
  38. case '待开始':
  39. this.text = '开始';
  40. this.id = 20230209144503;
  41. this.tips = '是否确定开始工单';
  42. this.toast = '工单开始成功!';
  43. break;
  44. case '进行中':
  45. this.text = '完结工单';
  46. this.id = 20230209144903;
  47. this.tips = '是否确定完结工单';
  48. this.toast = '工单完结成功!';
  49. break;
  50. default:
  51. this.text = '';
  52. this.id = "";
  53. this.tips = '';
  54. this.toast = '';
  55. this.$emit("unShowBut", false)
  56. break;
  57. }
  58. }
  59. },
  60. data() {
  61. return {
  62. loading: false,
  63. text: ""
  64. }
  65. },
  66. methods: {
  67. onClick(e) {
  68. if (!this.text) return;
  69. let that = this;
  70. uni.showModal({
  71. title: '提示',
  72. content: e ? `工单还未${this.text},${this.tips}` : this.tips,
  73. success: ({ confirm }) => {
  74. if (confirm) {
  75. that.loading = true;
  76. that.$Http.basic({
  77. "id": that.id,
  78. "version": 1,
  79. "content": {
  80. "sa_workorderid": that.sa_workorderid
  81. }
  82. }).then(res => {
  83. console.log(that.text + '工单', res)
  84. if (this.text == '完结工单' && res.msg != '成功') {
  85. that.loading = false;
  86. uni.showModal({
  87. title: '提示',
  88. content: res.msg,
  89. showCancel: false,
  90. });
  91. return;
  92. }
  93. if (that.cutoff(res.msg, this.toast)) return that.loading = false;
  94. this.$Http.updateWorkorder && this.$Http.updateWorkorder();
  95. that.$emit("onUpdate", true)
  96. })
  97. }
  98. },
  99. })
  100. }
  101. },
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .but-box {
  106. position: absolute;
  107. width: 100vw;
  108. bottom: 30px;
  109. display: flex;
  110. justify-content: center;
  111. /deep/ .u-button__text,
  112. /deep/.u-button__loading-text {
  113. font-size: 14px !important;
  114. }
  115. /deep/.u-loading-icon__spinner {
  116. width: 17.25px !important;
  117. height: 17.25px !important;
  118. }
  119. }
  120. </style>