用jsx写iveiw的$Modal.confirm,并且异步关闭弹窗,loading还可以重置(buttonLoading)

公冶高峯
2023-12-01
let self = this
this.$Modal.confirm({
          title: '发货',
          render: () => {
			return (
				<i-form model={this.form} label-width={80} rules={this.rules} ref="form">
					<form-item label="物流公司" prop="expressName">
						<i-input value={this.form.expressName} placeholder="请输入物流公司" onOn-change={(e) => this.onChangeText(e, 'expressName')}></i-input>
					</form-item>
					<form-item label="物流单号" class="require-nature ">
						{this.expressNos.map((item, index) => (
							<div class="flex item-center mb" key={item.key}>
								<i-input
									key={item.key}
									value={item.value}
									class="mr"
									placeholder="请输入发货单号"
									onOn-change={(e) => this.onInputExpressNo(e, index)}
								/>
								{index === 0 ? (
									<icon type="md-add-circle" size="20" onClick={this.onAddExpress} />
								) : (
									<icon type="md-remove-circle" size="20" onClick={() => this.onRemoveExpress(index)} />
								)}
							</div>
						))}
					</form-item>
					<form-item label="发货仓库" prop="shipStoreHouse">
						<i-input value={this.form.shipStoreHouse} onOn-change={(e) => this.onChangeText(e, 'shipStoreHouse')} placeholder="请输入发货仓库"></i-input>
					</form-item>
				</i-form>
			)
          },
		loading: true,
        onOk: function () {
						self.$refs['form'].validate((valid) => {
							if (valid) {
								let params = {
									orderId: self.data[0].orderId,
									expressName: self.form.expressName,
									shipStoreHouse: self.form.shipStoreHouse
								}
								self.$jsonPost('/integral/order/singRowShip', params).then((res) => {
									self.$Notice.success({
										title: '发货成功',
									})
									self.$Modal.remove()
								})
							} else {
								setTimeout(() => {
									// 这里的this指向的是当前的Modal对象,buttonLoading是他的私有属性,这样可以实现
									this.buttonLoading = false 
								}, 200)
							}
						})
          },
        })

 类似资料: