123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <template>
- <view class="but-box" v-if="text">
- <view style="width: 75vw;">
- <u-button type="primary" :text="text" color="rgba(42,106,242,.8)" loadingText="执行中..." :loading="loading"
- @click="onClick(false)" />
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "but",
- props: {
- sa_workorderid: {
- type: [String, Number],
- default: 0
- },
- status: {
- type: String
- },
- onUpdate: {
- type: Function
- },
- unShowBut: {
- type: Function
- }
- },
- watch: {
- status: function (newVal) {
- this.loading = false;
- this.$emit("unShowBut", true)
- switch (newVal) {
- case '待接单':
- this.text = '接单';
- this.id = 20230210101103;
- this.tips = '是否确定接收工单';
- this.toast = '工单接单成功!';
- break;
- case '待开始':
- this.text = '开始';
- this.id = 20230209144503;
- this.tips = '是否确定开始工单';
- this.toast = '工单开始成功!';
- break;
- case '进行中':
- this.text = '完结工单';
- this.id = 20230209144903;
- this.tips = '是否确定完结工单';
- this.toast = '工单完结成功!';
- break;
- default:
- this.text = '';
- this.id = "";
- this.tips = '';
- this.toast = '';
- this.$emit("unShowBut", false)
- break;
- }
- }
- },
- data() {
- return {
- loading: false,
- text: ""
- }
- },
- methods: {
- onClick(e) {
- if (!this.text) return;
- let that = this;
- uni.showModal({
- title: '提示',
- content: e ? `工单还未${this.text},${this.tips}` : this.tips,
- success: ({ confirm }) => {
- if (confirm) {
- that.loading = true;
- that.$Http.basic({
- "id": that.id,
- "version": 1,
- "content": {
- "sa_workorderid": that.sa_workorderid
- }
- }).then(res => {
- console.log(that.text + '工单', res)
- if (this.text == '完结工单' && res.msg != '成功') {
- that.loading = false;
- uni.showModal({
- title: '提示',
- content: res.msg,
- showCancel: false,
- });
- return;
- }
- if (that.cutoff(res.msg, this.toast)) return that.loading = false;
- this.$Http.updateWorkorder && this.$Http.updateWorkorder();
- that.$emit("onUpdate", true)
- })
- }
- },
- })
- }
- },
- }
- </script>
- <style lang="scss" scoped>
- .but-box {
- position: absolute;
- width: 100vw;
- bottom: 30px;
- display: flex;
- justify-content: center;
- /deep/ .u-button__text,
- /deep/.u-button__loading-text {
- font-size: 14px !important;
- }
- /deep/.u-loading-icon__spinner {
- width: 17.25px !important;
- height: 17.25px !important;
- }
- }
- </style>
|