|
|
@@ -57,8 +57,8 @@
|
|
|
|
|
|
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
|
- <el-form-item label="订单号" prop="orderCode">
|
|
|
- <el-input v-model="form.orderCode" placeholder="请输入订单号" />
|
|
|
+ <el-form-item label="手写信息采集表" prop="billImgUrl">
|
|
|
+ <image-upload v-model="form.billImgUrl" :limit="1" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="患者姓名" prop="patientName">
|
|
|
<el-input v-model="form.patientName" placeholder="请输入患者姓名" />
|
|
|
@@ -66,9 +66,10 @@
|
|
|
<el-form-item label="患者电话" prop="patientPhone">
|
|
|
<el-input v-model="form.patientPhone" placeholder="请输入患者电话" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="手写信息采集表" prop="billImgUrl">
|
|
|
- <image-upload v-model="form.billImgUrl" :limit="1" />
|
|
|
+ <el-form-item label="订单号" prop="orderCode">
|
|
|
+ <el-input v-model="form.orderCode" placeholder="请输入订单号" />
|
|
|
</el-form-item>
|
|
|
+
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
@@ -79,7 +80,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { listCollection, getCollection, addCollection, updateCollection, delCollection } from "@/api/member/handwriteCollection/handwriteCollection";
|
|
|
+import { listCollection, getCollection, addCollection, updateCollection, delCollection, checkOrderCode } from "@/api/member/handwriteCollection/handwriteCollection";
|
|
|
import ImageUpload from "@/components/ImageUpload";
|
|
|
|
|
|
export default {
|
|
|
@@ -96,6 +97,8 @@ export default {
|
|
|
ids: [],
|
|
|
single: true,
|
|
|
multiple: true,
|
|
|
+ // 记录原始订单号,用于修改时判断是否变化
|
|
|
+ originalOrderCode: null,
|
|
|
queryParams: {
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
@@ -111,6 +114,9 @@ export default {
|
|
|
patientPhone: [
|
|
|
{ required: true, message: "患者电话不能为空", trigger: "blur" },
|
|
|
{ pattern: /^1[3-9]\d{9}$/, message: "请输入正确的手机号码", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ orderCode: [
|
|
|
+ { required: true, message: "订单号不能为空", trigger: "blur" }
|
|
|
]
|
|
|
}
|
|
|
};
|
|
|
@@ -145,14 +151,40 @@ export default {
|
|
|
const id = row.id || this.ids[0];
|
|
|
getCollection(id).then(response => {
|
|
|
this.form = response.data;
|
|
|
+ // 保存原始订单号
|
|
|
+ this.originalOrderCode = this.form.orderCode;
|
|
|
this.open = true;
|
|
|
this.title = "修改手写信息采集表";
|
|
|
});
|
|
|
},
|
|
|
- submitForm() {
|
|
|
- this.$refs.form.validate(valid => {
|
|
|
+ // 修改 submitForm 为异步方法
|
|
|
+ async submitForm() {
|
|
|
+ this.$refs.form.validate(async (valid) => {
|
|
|
if (valid) {
|
|
|
- if (this.form.id != null) {
|
|
|
+ const isUpdate = this.form.id != null;
|
|
|
+ let needCheckOrder = true;
|
|
|
+
|
|
|
+ // 如果是修改,且订单号未改变,则不需要校验
|
|
|
+ if (isUpdate && this.form.orderCode === this.originalOrderCode) {
|
|
|
+ needCheckOrder = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 需要校验订单号(新增时 always true,修改时订单号改变则校验)
|
|
|
+ if (needCheckOrder && this.form.orderCode) {
|
|
|
+ try {
|
|
|
+ const res = await checkOrderCode(this.form.orderCode);
|
|
|
+ if (res.code !== 200) {
|
|
|
+ this.$message.error(res.msg || "订单号校验失败,请检查");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error("订单号校验请求失败");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验通过,执行新增/修改
|
|
|
+ if (isUpdate) {
|
|
|
updateCollection(this.form).then(() => {
|
|
|
this.$message.success("修改成功");
|
|
|
this.open = false;
|
|
|
@@ -194,6 +226,8 @@ export default {
|
|
|
billImgUrl: null,
|
|
|
orderCode: null
|
|
|
};
|
|
|
+ // 重置原始订单号
|
|
|
+ this.originalOrderCode = null;
|
|
|
if (this.$refs.form) {
|
|
|
this.$refs.form.resetFields();
|
|
|
}
|