戴艳蓉 3 years ago
parent
commit
5461500cef

+ 6 - 0
src/apis/components/abnormal-cause.js

@@ -0,0 +1,6 @@
+import http from "@/apis/axios";
+const api = "admin/";
+export default {
+  // 列表
+  list: (data, params) => http(api + "resultlist", data, "post", params),
+};

+ 0 - 24
src/apis/service/searchSelect/index.js

@@ -1,24 +0,0 @@
-// 账号
-import http from '@/apis/axios'
-const api = 'admin/'
-export default {
-
-
-  // 获取全部部门
-  list1: (data, params) => http(api + 'userlist', data, 'post', params),
-  // 详情
-  detail: (data, params) => http(api + 'userinfo', data, 'post', params),
-  // 更新
-  update: (data, params) => http(api + 'usersave', data, 'post', params),
-
-  // 添加
-  add: (data, params) => http(api + 'accountadd', data, 'post', params),
-  // 删除
-  delete: (data, params) => http(api + 'delete', data, 'post', params),
-  // 修改密码
-  setpwd: (data, params) => http(api + 'passset', data, 'post', params),
-  // 修改状态
-  status: (data, params) => http(api + 'userstatus', data, 'post', params),
-  // 拉取角色列表
-  getRole: (data, params) => http(api + 'roleall', data, 'post', params)
-}

+ 25 - 56
src/views/sheetOrder/zxAfterSaleOrder/components/addEditModel.vue → src/components/abnormal-condition-modal/index.vue

@@ -35,21 +35,12 @@
               </el-col>
               <el-col :span="24">
                 <el-form-item label="异常原因" prop="error_code">
-                  <el-select
-                    @change="handleValue"
-                    style="width: 100%"
-                    v-model="ruleForm.error_code"
-                    placeholder="请选择异常原因"
-                  >
-                    <el-option
-                      v-for="item in error_code_options"
-                      :key="item.id"
-                      :label="item.result"
-                      :value="item.result_code"
-                      :disabled="item.status == 0"
-                    >
-                    </el-option>
-                  </el-select>
+                  <abnormal-cause
+                    :value="ruleForm.error_code"
+                    :placeholder="'请选择异常原因'"
+                    :disabled="false"
+                    @searchChange="select_change"
+                  />
                 </el-form-item>
               </el-col>
               <el-col :span="24">
@@ -57,7 +48,7 @@
                   <el-input
                     type="textarea"
                     :rows="3"
-                    placeholder="请输入异常原因备注"
+                    placeholder="请输入异常备注"
                     v-model="ruleForm.error_remark"
                     maxlength="250"
                     show-word-limit
@@ -68,24 +59,19 @@
           </el-form>
         </el-col>
         <el-col :span="24" style="text-align: right">
-          <el-button type="primary" @click="submitForm" v-if="!isDetail"
-            >保 存
-          </el-button>
-          <el-button @click="showModelThis = false">{{
-            isDetail ? "关 闭" : "取 消"
-          }}</el-button>
+          <el-button type="primary" @click="submitForm">保 存 </el-button>
+          <el-button @click="showModelThis = false">关 闭</el-button>
         </el-col>
       </el-row>
     </el-card>
   </el-dialog>
 </template>
    <script>
-import asyncRequest from "@/apis/service/sellOut/returnOrder";
 import resToken from "@/mixins/resToken";
 import { isnumber } from "@/utils/validate";
 export default {
   name: "returnOrder",
-  props: ["showModel", "id", "sitem"],
+  props: ["showModel", "index", "sitem"],
   mixins: [resToken],
   data() {
     const validateerror_num = (rule, value, callback) => {
@@ -107,10 +93,9 @@ export default {
         error_num: "", //异常数量
         error_code: "", //异常原因
         error_remark: "", //异常备注
-        name: "",
-        status: "1",
+        error_code_name: "",
+        id: "",
       },
-      error_code_options: [],
       rulesThis: this.rules,
       rules: {
         error_num: [
@@ -153,10 +138,9 @@ export default {
 
   methods: {
     async initForm() {
-      await this.geterror_code();
       this.loading = true;
       this.rulesThis = this.rules;
-      if (this.id === -1) {
+      if (this.index === -1) {
         this.title = "添加异常情况";
       } else {
         this.title = "编辑异常情况";
@@ -170,10 +154,10 @@ export default {
         if (this.$refs.ruleForm) {
           this.$refs.ruleForm.resetFields();
           this.$refs.ruleForm.clearValidate();
-          const { error_num, error_code, error_remark, error_code_name } =
+          const { error_num, error_code, error_remark, error_code_name, id } =
             this.sitem;
-            console.log(this.sitem)
           this.ruleForm = {
+            id: id || "",
             error_num: error_num || "", //异常数量
             error_code: error_code || "", //异常原因
             error_remark: error_remark || "", //异常备注
@@ -187,37 +171,22 @@ export default {
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
           this.showModelThis = false;
-          this.$emit("refresh", { index: this.id, item: this.ruleForm });
+          this.$emit("refresh", {
+            index: this.index,
+            item: JSON.parse(JSON.stringify(this.ruleForm)),
+          });
         } else {
           console.log("error submit!!");
           return false;
         }
       });
     },
-    // 异常原因
-    async geterror_code() {
-      let model = {
-        type: "5",
-        page: 1,
-        size: 100,
-      };
-      const res = await asyncRequest.resultlist(model);
-      this.loading = false;
-      if (res && res.code === 0) {
-        this.error_code_options = res.data.list;
-      } else if (res && res.code >= 100 && res.code <= 104) {
-        await this.logout();
-      } else {
-        this.$message.warning(res.message);
-      }
-    },
-    handleValue(e) {
-      let findex = this.error_code_options.findIndex(
-        (v) => v.result_code === e
-      );
-      if (findex) {
-        this.ruleForm.error_code_name = this.error_code_options[findex].result;
-      }
+
+    select_change(e) {
+      this.ruleForm.error_code = e && e.code ? e.code : "";
+      this.ruleForm.error_code_name = e && e.code ? e.label : "";
+      this.$refs.ruleForm.validateField("error_code_name");
+      this.$refs.ruleForm.validateField("error_code");
     },
   },
 };

+ 0 - 0
src/components/abnormal-condition-modal/异常情况弹窗


+ 2 - 0
src/components/globalComponents/abnormal-cause/index.js

@@ -0,0 +1,2 @@
+import Main from './main.vue'
+export default Main

+ 139 - 0
src/components/globalComponents/abnormal-cause/main.vue

@@ -0,0 +1,139 @@
+<template>
+  <el-select
+    v-model="value"
+    :size="size || 'medium'"
+    style="width: 100%"
+    :placeholder="placeholder || ''"
+    :disabled="disabled"
+    @change="selectChange"
+  >
+    <el-option
+      v-for="item in options"
+      :key="item.result_code"
+      :label="item.result"
+      :value="item.result_code"
+      :disabled="item.status==='0'"
+    >
+    </el-option>
+  </el-select>
+  <!-- <el-select
+    v-model="value"
+    multiple
+    filterable
+    remote
+    :multiple-limit="1"
+    reserve-keyword
+    :size="size || 'medium'"
+    style="width: 100%"
+    :placeholder="placeholder||''"
+    :disabled="disabled"
+    :remote-method="getList"
+    :loading="selectLoading"
+    @change="selectChange"
+  >
+    <el-option
+      v-for="(item, index) in options"
+      :key="item.id + index"
+      :label="item.name"
+      :value="item.code+''"
+      :disabled="item.status!=='1'"
+    >
+    </el-option>
+  </el-select> -->
+</template>
+
+<script>
+import asyncRequest from "@/apis/components/abnormal-cause";
+import resToken from "@/mixins/resToken";
+export default {
+  name: "abnormalCause",
+  mixins: [resToken],
+  props: [
+    "size",
+    "value",
+    "placeholder",
+    "isDetail",
+    "disabled",
+    "names",
+    "type",
+  ],
+  /**
+   * 属性集合
+   * @param {String}        size             : 组件大小            非必填
+   * @param {String}        value            : 选中值              必填
+   * @param {String}        placeholder      : 提示信息            非必填
+   * @param {Boolean}       isDetail          : 是否是详情逻辑       必填
+   * @param {Boolean}       disabled         : 是否禁用            必填
+   * @param {String}        names            : 选中值label         展示详情必填
+   * @param {String}        type             : 数据类型            非必填 1是平台供应商0非平台供应商
+   */
+  /**
+   * 事件集合
+   * @searchChange             : 选中值变化调用   抛出选中数据
+   */
+  data() {
+    return {
+      options: [],
+      selectLoading: false,
+      searchName: "",
+    };
+  },
+  watch: {
+    names: function (val, old) {
+      // console.log(val, old);
+      this.searchName = val;
+      if (this.isDetail && this.searchName) {
+        this.getList(this.searchName);
+      }
+    },
+  },
+  mounted() {
+    this.options = [];
+    this.selectLoading = false;
+    this.getList()
+  },
+  methods: {
+    async selectChange(e) {
+      if (e) {
+        let index = this.options.findIndex((v) => v.result_code === e);
+        if (index !== -1) {
+          let model = {
+            id: this.options[index].id,
+            code: this.options[index].result_code,
+            label: this.options[index].result,
+          };
+          this.$emit("searchChange", model);
+        } else {
+          this.$emit("searchChange", {});
+        }
+      } else {
+        this.$emit("searchChange", {});
+      }
+    },
+    async getList() {
+      this.selectLoading = true;
+      this.options = [];
+      let formValue = {
+        type: this.type || "1",
+        page: 1,
+        size: 500,
+      };
+
+      let res = await asyncRequest.list(formValue);
+      if (res && res.code === 0 && res.data) {
+        const { list } = res.data;
+        this.options = list;
+      } else if (res && res.code >= 100 && res.code <= 104) {
+        await this.logout();
+      } else {
+        this.$message.warning(res.message);
+      }
+
+      this.selectLoading = false;
+    },
+  },
+};
+</script>
+
+<style>
+</style>

+ 0 - 0
src/components/globalComponents/abnormal-cause/异常原因选择组件


+ 0 - 228
src/views/sellOut/returnOrder/components/addEdit.vue

@@ -1,228 +0,0 @@
-<template>
-  <el-dialog
-    :title="title"
-    :center="true"
-    align="left"
-    top="5vh"
-    width="1040px"
-    @close="showModelThis = false"
-    :close-on-click-modal="false"
-    :visible.sync="showModelThis"
-    v-loading="loading"
-    element-loading-text="拼命加载中"
-    element-loading-spinner="el-icon-loading"
-    element-loading-background="rgba(0, 0, 0, 0.8)"
-  >
-    <el-card>
-      this.showModel,{{ showModel }} showModelThis:{{ showModelThis }}
-      <el-row :gutter="10">
-        <el-col :span="24">
-          <el-form
-            :model="ruleForm"
-            status-icon
-            :rules="rulesThis"
-            ref="ruleForm"
-            label-width="110px"
-            class="demo-ruleForm"
-          >
-            <el-row>
-              <el-col :span="12">
-                <el-form-item label="异常数量" prop="numbers">
-                  <el-input
-                    :disabled="disabled"
-                    v-model="ruleForm.numbers"
-                    placeholder="请输入异常数量"
-                  ></el-input>
-                </el-form-item>
-              </el-col>
-              <el-col :span="12">
-                <el-form-item label="异常原因" prop="reason">
-                  <el-select
-                    @change="handleValue"
-                    style="width: 100%"
-                    :disabled="disabled"
-                    v-model="ruleForm.reason"
-                    placeholder="请选择异常原因"
-                  >
-                    <el-option
-                      v-for="item in reason_options"
-                      :key="item.id"
-                      :label="item.result"
-                      :value="item.result_code"
-                      :disabled="item.status == 0"
-                    >
-                    </el-option>
-                  </el-select>
-                </el-form-item>
-              </el-col>
-              <el-col :span="12">
-                <el-form-item label="异常备注" prop="remark">
-                  <el-input
-                    type="textarea"
-                    placeholder="请输入异常原因备注"
-                    v-model="ruleForm.remark"
-                    :disabled="disabled"
-                    maxlength="250"
-                    show-word-limit
-                  />
-                </el-form-item>
-              </el-col>
-            </el-row>
-          </el-form>
-        </el-col>
-        <el-col :span="24" style="text-align: right">
-          <el-button type="primary" @click="submitForm" v-if="!isDetail"
-            >保 存
-          </el-button>
-          <el-button @click="showModelThis = false">{{
-            isDetail ? "关 闭" : "取 消"
-          }}</el-button>
-        </el-col>
-      </el-row>
-    </el-card>
-  </el-dialog>
-</template>
-   <script>
-import asyncRequest from "@/apis/service/sellOut/returnOrder";
-import resToken from "@/mixins/resToken";
-import { isnumber } from "@/utils/validate";
-export default {
-  name: "returnOrder",
-  props: ["showModel", "id", "isDetail", "sitem"],
-  mixins: [resToken],
-  data() {
-    const validatenumbers = (rule, value, callback) => {
-      if (value === "") {
-        callback(new Error("异常数量不能为空!"));
-      } else {
-        if (!isnumber(value)) {
-          callback(new Error("异常数量必须为数字"));
-        } else {
-          callback();
-        }
-      }
-    };
-    return {
-      loading: false,
-      title: "添加异常情况",
-      showModelThis: this.showModel,
-      ruleForm: {
-        numbers: "", //异常数量
-        reason: "", //异常原因
-        remark: "", //异常备注
-        name: "",
-        status: "1",
-      },
-      reason_options: [],
-      rulesThis: this.rules,
-      rules: {
-        numbers: [
-          {
-            required: true,
-            validator: validatenumbers,
-            trigger: "blur",
-          },
-        ],
-        reason: [
-          {
-            required: true,
-            // validator: validateusername,
-            message: "请输入异常原因",
-            trigger: "blur",
-          },
-        ],
-        remark: [
-          {
-            required: true,
-            message: "请填写异常原因备注",
-            trigger: "blur",
-          },
-        ],
-      },
-    };
-  },
-  watch: {
-    showModel: function (val) {
-      this.showModelThis = val;
-      if (val) {
-        this.initForm();
-      }
-    },
-    showModelThis(val) {
-      if (!val) {
-        this.$emit("cancel");
-      }
-    },
-  },
-  // mounted() {
-  //   this.initForm();
-  // },
-  methods: {
-    
-    async initForm() {
-      await this.getReason();
-      this.loading = true;
-      this.rulesThis = this.rules;
-      await this.resetForm();
-      this.loading = false;
-    },
-    async resetForm() {
-      // 重置
-      await this.$nextTick(() => {
-        if (this.$refs.ruleForm) {
-          this.$refs.ruleForm.resetFields();
-          this.$refs.ruleForm.clearValidate();
-
-          this.ruleForm = {
-            numbers: "", //异常数量
-            reason: "", //异常原因
-            remark: "", //异常备注
-            name: "",
-          };
-        }
-      });
-    },
-
-    async submitForm() {
-      await this.$refs.ruleForm.validate(async (valid) => {
-        if (valid) {
-          // this.loading = true;
-          this.showModelThis = false;
-          this.$emit("refresh", this.ruleForm);
-        } else {
-          console.log("error submit!!");
-          return false;
-        }
-      });
-    },
-    // 异常原因
-    async getReason() {
-      let model = {
-        type: "5",
-        page: 1,
-        size: 100,
-      };
-      const res = await asyncRequest.resultlist(model);
-      this.loading = false;
-      if (res && res.code === 0) {
-        this.reason_options = res.data.list;
-      } else if (res && res.code >= 100 && res.code <= 104) {
-        await this.logout();
-      } else {
-        this.$message.warning(res.message);
-      }
-    },
-    handleValue(e) {
-      this.reason_options.forEach((item) => {
-        if (item.result_code === e) {
-          this.ruleForm.name = item.result;
-        }
-      });
-    },
-  },
-};
-</script>
-
-   <style lang="scss" scoped>
-</style>
-   

+ 152 - 345
src/views/sellOut/returnOrder/components/return-record.vue

@@ -9,7 +9,6 @@
     style="width: 100%"
     class="demo-ruleForm"
   >
-    <p>sitem:{{ status }}</p>
     <el-row>
       <el-col :span="12">
         <el-form-item label="退货总数量" prop="return_num">
@@ -19,12 +18,13 @@
             placeholder="退货总数量"
           ></el-input>
         </el-form-item>
-      
       </el-col>
       <el-col :span="12">
         <el-form-item label="可销售数量" prop="normal">
           <el-input
-            :disabled="status != '1' && status != '0'"
+            :disabled="
+              !(status === '0' && powers.some((item) => item == '047'))
+            "
             v-model="ruleForm.normal"
             placeholder="可销售数量"
           ></el-input>
@@ -33,7 +33,9 @@
       <el-col :span="24">
         <el-form-item label="其他备注" prop="remark">
           <el-input
-            :disabled="status != '1' && status != '0'"
+            :disabled="
+              !(status === '0' && powers.some((item) => item == '047'))
+            "
             type="textarea"
             maxlength="250"
             show-word-limit
@@ -44,200 +46,90 @@
         </el-form-item>
       </el-col>
       <el-col :span="24">
-        <el-form-item label="异常情况记录">
-          <!-- <span>异常情况记录</span> -->
-          <!-- <AnomalousRecord :sitem="sitem"></AnomalousRecord> -->
-          <el-row>
-            <el-col :span="24">
-              <el-form
-                :model="ruleForm"
-                :rules="tableFormThis"
-                ref="ruleForm"
-                :size="'mini'"
-                class="demo-tableForm product_go"
+        <el-form-item label="异常情况记录" :size="'mini'">
+          <el-form
+            :model="ruleForm"
+            :rules="tableFormThis"
+            ref="ruleForm"
+            :size="'mini'"
+            class="demo-tableForm product_go"
+          >
+            <el-table
+              :data="ruleForm.product_go"
+              border
+              :size="'mini'"
+              row-key="key"
+            >
+              <el-table-column label="异常数量" prop="error_num" />
+              <el-table-column label="异常原因" prop="error_code_name" />
+              <el-table-column label="异常备注" prop="error_remark" />
+              <el-table-column
+                fixed="right"
+                label="操作"
+                width="80"
+                v-if="status === '0' && powers.some((item) => item == '047')"
               >
-                <!-- {{ tableForm.product_go }} -->
-
-                <!-- {{ options }} -->
-                <el-table
-                  :data="ruleForm.product_go"
-                  border
-                  :size="'mini'"
-                  row-key="key"
-                >
-                  <el-table-column label="异常数量">
-                    <template slot-scope="scope">
-                      <el-form-item
-                        :style="!scope.row.edit ? 'margin:0' : ''"
-                        :prop="
-                          'product_go.' + scope.$index + '.anomalous_numbers'
-                        "
-                        :rules="{
-                          required: true,
-                          message: '异常数量不能为空',
-                          trigger: 'blur',
-                        }"
-                      >
-                        <el-input
-                          :disabled="!scope.row.edit"
-                          v-model="scope.row.anomalous_numbers"
-                          placeholder="请输入异常数量"
-                        ></el-input>
-                      </el-form-item>
-                    </template>
-                  </el-table-column>
-                  <el-table-column label="异常原因">
-                    <template slot-scope="scope">
-                      <el-form-item
-                        :style="!scope.row.edit ? 'margin:0' : ''"
-                        :prop="
-                          'product_go.' + scope.$index + '.anomalous_reason'
-                        "
-                      >
-                        <el-select
-                          style="width: 100%"
-                          :disabled="!scope.row.edit"
-                          v-model="scope.row.anomalous_reason_code"
-                          placeholder="异常原因"
-                        >
-                          <el-option
-                            :disabled="item.status == 0"
-                            v-for="item in options"
-                            :key="item.id"
-                            :label="item.result"
-                            :value="item.result_code"
-                          >
-                          </el-option>
-                        </el-select>
-                      </el-form-item>
-                    </template>
-                  </el-table-column>
-                  <el-table-column label="异常备注">
-                    <template slot-scope="scope">
-                      <el-form-item
-                        :style="!scope.row.edit ? 'margin:0' : ''"
-                        :prop="
-                          'product_go.' + scope.$index + '.anomalous_remark'
-                        "
-                        :rules="{
-                          required: true,
-                          message: '异常备注不能为空',
-                          trigger: 'blur',
-                        }"
-                      >
-                        <el-input
-                          placeholder="异常备注"
-                          :disabled="!scope.row.edit"
-                          v-model="scope.row.anomalous_remark"
-                        ></el-input>
-                      </el-form-item>
-                    </template>
-                  </el-table-column>
-
-                  <el-table-column fixed="right" label="操作" width="80">
-                    <template slot="header" slot-scope="scope">
-                      <span>操作</span>
-                      <el-tooltip
-                        class="fr"
-                        style="margin: 3px 0 0 0"
-                        effect="dark"
-                        content="添加"
-                        placement="top"
-                      >
-                        <i
-                          v-if="status == '1' || status == '0'"
-                          class="el-icon-circle-plus-outline tb-icon"
-                          style="color: #63cbe7"
-                          @click="openModal('add', '028')"
-                        ></i>
-                      </el-tooltip>
-                    </template>
-                    <template
-                      slot-scope="scope"
-                      v-if="status == '1' || status == '0'"
-                    >
-                      <el-tooltip
-                        effect="dark"
-                        content="编辑"
-                        v-if="!scope.row.edit"
-                        placement="top"
-                      >
-                        <i
-                          class="el-icon-edit tb-icon"
-                          @click="editRow(scope.$index)"
-                        ></i>
-                      </el-tooltip>
-                      <el-tooltip
-                        effect="dark"
-                        content="保存"
-                        v-if="scope.row.edit"
-                        placement="top"
-                      >
-                        <i
-                          class="el-icon-circle-check tb-icon"
-                          @click="checkRow(scope.$index)"
-                        ></i>
-                      </el-tooltip>
+                <template slot="header" slot-scope="scope">
+                  <!-- v-if="status == '1' || status == '0'" -->
+                  <span>操作</span>
+                  <el-tooltip
+                    class="fr"
+                    style="margin: 3px 0 0 0"
+                    effect="dark"
+                    content="添加"
+                    placement="top"
+                  >
+                    <i
+                      class="el-icon-circle-plus-outline tb-icon"
+                      style="color: #63cbe7"
+                      @click="openModal(-1)"
+                    ></i>
+                  </el-tooltip>
+                </template>
+                <!-- v-if="status == '1' || status == '0'" -->
+                <template slot-scope="scope">
+                  <el-tooltip
+                    effect="dark"
+                    content="编辑"
+                    v-if="!scope.row.edit"
+                    placement="top"
+                  >
+                    <i
+                      class="el-icon-edit tb-icon"
+                      @click="openModal(scope.$index)"
+                    ></i>
+                  </el-tooltip>
 
-                      <el-tooltip effect="dark" content="删除" placement="top">
-                        <i
-                          class="el-icon-delete-solid tb-icon"
-                          @click="deleteRow(scope.$index)"
-                        ></i>
-                      </el-tooltip>
-                    </template>
-                  </el-table-column>
-                </el-table>
-              </el-form>
-            </el-col>
-          </el-row>
+                  <el-tooltip
+                    v-if="scope.row.edit"
+                    effect="dark"
+                    content="重置"
+                    placement="top"
+                  >
+                    <i
+                      class="el-icon-delete tb-icon"
+                      @click="deleteRow(scope.$index, ruleForm.product_go)"
+                    ></i>
+                  </el-tooltip>
+                </template>
+              </el-table-column>
+            </el-table>
+          </el-form>
         </el-form-item>
       </el-col>
-    </el-row>
-
-    <el-row>
-      <el-col :span="24" style="text-align: right; margin: 10px 0 20px 0">
-        <el-button
-          v-if="status == '0' || status == '1'"
-          type="primary"
-          class="fr"
-          :size="'mini'"
-          @click="submitForm"
+      <el-col
+        :span="24"
+        style="text-align: right; margin: -5px 0 20px 0"
+        v-if="status === '0' && powers.some((item) => item == '047')"
+      >
+        <el-button type="primary" class="fr" :size="'mini'" @click="submitForm"
           >保 存
         </el-button>
-        <el-button
-          type="primary"
-          @click="statusConfirm('1', '发起审核流程')"
-          v-if="status === '0' && powers.some((item) => item == '012')"
-          >发起审核流程
-        </el-button>
-        <el-button
-          @click="statusConfirm('0', '取消审核流程')"
-          plain
-          v-if="status === '1' && powers.some((item) => item == '014')"
-          >取消审核流程</el-button
-        >
-        <el-button
-          @click="statusConfirm('-1', '作废该条信息')"
-          type="danger"
-          plain
-          v-if="
-            (status === '0' || status === '1') &&
-            powers.some((item) => item == '015')
-          "
-          >作废该条信息</el-button
-        >
-        <el-button
-          @click="statusConfirm('2', '通过审核')"
-          type="primary"
-          v-if="status === '1' && powers.some((item) => item == '016')"
-          >通过审核</el-button
-        >
       </el-col>
     </el-row>
-    <add-edit
-      :id="modelId"
-      :sitem="sitem"
+    <abnormal-condition-modal
+      :index="index"
+      :sitem="s_item"
       :show-model="showModel"
       @refresh="handleValue"
       @cancel="showModel = false"
@@ -247,14 +139,13 @@
 <script>
 import asyncRequest from "@/apis/service/sellOut/returnOrder";
 import resToken from "@/mixins/resToken";
-import { isnumber } from "@/utils/validate.js";
-import addEdit from "./addEdit.vue";
+import { isnumber } from "@/utils/validate";
+import abnormalConditionModal from "@/components/abnormal-condition-modal";
 export default {
-  name: "returnRecord",
+  name: "zxAfterSaleOrderDetail",
   props: ["id", "showModelThis", "newTime", "sitem"],
   mixins: [resToken],
-  components: { addEdit },
-  // props: ["sitem"],
+  components: { abnormalConditionModal },
   data() {
     const validatenumbers = (rule, value, callback) => {
       if (value === "") {
@@ -268,21 +159,21 @@ export default {
       }
     };
     return {
-      newArr: [], //存储异常记录列表项
       arr: [],
+      s_item: null,
       sitemGetNumber: "", //详情总收货量
       isShow: false, //用于情况1
       returnNO: "", //退货编号
       ruleForm: {
-        return_num: "", //
+        return_num: "", //收货总数量
         normal: "", //可销售数量
         remark: "", //其他备注
         product_go: [], //表格参数
       },
+
       btn_code: "",
-      modelId: "",
+      index: "",
       options: [],
-      voList: [],
       edit: false, //默认不能提交
       totalNumber: 0, //全局保存数量
       loading: false,
@@ -298,7 +189,7 @@ export default {
             trigger: "blur",
             validator: validatenumbers,
           },
-        ], 
+        ],
         normal: [
           {
             required: true,
@@ -320,7 +211,7 @@ export default {
     powers() {
       let tran =
         this.$store.getters.btnList.find(
-          (item) => item.menu_route == "returnRecord"
+          (item) => item.menu_route == "zxAfterSaleOrderDetail"
         ) || {};
       if (tran && tran.action && tran.action.length > 0) {
         return tran.action;
@@ -330,15 +221,10 @@ export default {
     },
   },
 
-  mounted() {
-    this.initForm();
-  },
+  // mounted() {
+  //   this.initForm();
+  // },
   watch: {
-    id: function (val) {
-      if (val) {
-        this.initForm();
-      }
-    },
     newTime: function (val) {
       if (val) {
         this.initForm();
@@ -346,11 +232,6 @@ export default {
     },
   },
   methods: {
-    //   关闭弹窗,直接隐藏表单
-    // async closeAddEdit() {
-    //   this.$emit("closeModel", false); //抛出一个事件,关闭弹窗
-    //
-    // },
     async initForm() {
       this.loading = true;
       this.rulesThis = this.rules;
@@ -367,25 +248,21 @@ export default {
           this.$refs.ruleForm.clearValidate();
           this.status = "";
           this.arr = [];
-          this.newArr = [];
-          let { child, status, received_num, normal_num, remark, return_num } =
-            this.sitem;
+          let { child, status, normal_num, remark, return_num } = this.sitem;
           this.status = status;
-          this.newArr = child;
-          child.forEach((ele) => {
-            let obj = {
-              is_del: "0",
-              anomalous_numbers: ele.error_num,
-              anomalous_reason_code: ele.error_code,
-              anomalous_remark: ele.error_remark,
-              id: ele.id,
-              edit: false,
-            };
-            this.arr.push(obj);
-          });
+          if (child) {
+            this.arr =
+              child && child.length > 0
+                ? JSON.parse(JSON.stringify(child))
+                : [];
+            this.arr.forEach((v) => {
+              v.is_del = "0";
+              v.error_code_name = v.error_msg;
+            });
+          }
           this.ruleForm = {
-            return_num: return_num,
-            normal: normal_num, //可销售数量
+            return_num: return_num || "",
+            normal: normal_num || "", //可销售数量
             remark: remark, //其他备注
             product_go: this.arr, //表格参数this.arr
           };
@@ -397,39 +274,24 @@ export default {
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
           this.loading = true;
-          const { product_go } = this.ruleForm;
-          let isok = true;
-          product_go.forEach((v) => {
-            if (v.edit) {
-              isok = false;
-            }
-          });
-          if (!isok) {
-            this.$message.warning("请保存异常情况记录表格!");
-            this.loading = false;
-            return;
+
+          let model = JSON.parse(JSON.stringify(this.ruleForm));
+          let list = JSON.parse(JSON.stringify(this.arr));
+          let { return_num, normal, product_go, remark } = model;
+          let errorT = 0;
+          if (product_go && product_go.length > 0) {
+            product_go.forEach((v) => {
+              errorT += parseInt(v.error_num);
+            });
           }
-          const {  normal } = this.ruleForm;
-          const { return_num } = this.sitem;
-          let a = 0;
-          product_go.forEach((x) => {
-            a += Number(x.anomalous_numbers);
-          });
 
-          if (Number(return_num) !== Number(normal) + a) {
-            this.$message.warning("可销售数量+异常总数量不等于总退回数量!");
+          if (parseInt(normal) + errorT !== parseInt(return_num)) {
+            this.$message.warning("可销售数量+异常总数量不等于退货总数量!");
             this.loading = false;
             return;
           }
-          let allList = [];
-          let model = JSON.parse(JSON.stringify(this.ruleForm));
-          delete model["product_go"];
-          model.errorlist = [];
-          model.thNo = this.sitem.thNo;
-
-          let list = JSON.parse(JSON.stringify(this.newArr));
           product_go.forEach((x) => {
-            let index = this.newArr.findIndex((y) => y.id === x.id);
+            let index = list.findIndex((y) => x.id === y.id);
             if (index !== -1) {
               list.splice(index, 1);
             }
@@ -437,20 +299,14 @@ export default {
           list.forEach((v) => {
             v.is_del = "1";
           });
-          allList.push(...product_go);
-          allList.push(...list);
+          let item = {
+            thNo: this.sitem.thNo,
+            normal,
+            remark,
+            errorlist: [].concat(product_go).concat(list),
+          };
 
-          allList.map((ele) => {
-            let obj = {
-              id: ele.id,
-              is_del: ele.is_del,
-              error_num: ele.anomalous_numbers || "",
-              error_code: ele.anomalous_reason_code || "",
-              error_remark: ele.anomalous_remark || "",
-            };
-            model.errorlist.push(obj);
-          });
-          const res = await asyncRequest.returnCheck(model); //退货验货接口
+          const res = await asyncRequest.returnCheck(item);
           this.loading = false;
           if (res && res.code === 0) {
             this.$notify.success({
@@ -472,7 +328,7 @@ export default {
         page: 1,
         size: 100,
         type: "1",
-        status: "3",
+        // status: "3",
       });
       if (res && res.code === 0 && res.data) {
         const { list } = res.data;
@@ -483,87 +339,38 @@ export default {
         this.$message.warning(res.message);
       }
     },
-    //保存某一行
-    checkRow(rowIndex) {
-      const { anomalous_numbers, anomalous_reason_code, anomalous_remark } =
-        this.ruleForm.product_go[rowIndex];
-      if (anomalous_numbers == "" && anomalous_remark == "") {
-        this.$message.warning("异常数量和异常备注不能为空!");
-        return;
-      }
-      if (!isnumber(anomalous_numbers)) {
-        this.$message.warning("异常数量必须为整数!");
-        return;
-      }
-      if (
-        +anomalous_numbers + +this.ruleForm.normal !==
-        +this.ruleForm.return_num
-      ) {
-        this.$message.warning("当前可销售数量+异常数量不等于总退货数量!");
-        return;
-      }
 
-      if (anomalous_numbers == 0) {
-        this.$message.info("异常数量为零,不用选择异常原因!");
-        this.ruleForm.product_go[rowIndex].edit = false;
-        return;
-      }
-      if (anomalous_reason_code == "") {
-        this.$message.warning("请选择异常原因!");
-        return;
-      }
-
-      this.ruleForm.product_go[rowIndex].edit = false;
-    },
-    //编辑某一行
-    editRow(rowIndex) {
-      let index = this.ruleForm.product_go.findIndex((v) => v.edit);
-      if (index !== -1) {
-        this.$message.warning("请完成其他行的编辑!");
-        return;
-      } else {
-        this.ruleForm.product_go[rowIndex].edit = true;
+    // 删除行操作
+    deleteRow(index, rows) {
+      if (this.id !== "add" && rows[index].id) {
+        this.delList.push(rows[index]);
       }
+      rows.splice(index, 1);
+      this.$refs.ruleForm.validateField("product_go");
     },
-    deleteRow(rowIndex) {
-      this.ruleForm.product_go.shift(rowIndex);
-    },
-    //重置行内参数
-    resetRow(rowIndex) {
-      this.ruleForm.product_go[rowIndex].anomalous_numbers = "";
-      this.ruleForm.product_go[rowIndex].anomalous_reason_code = "";
-      this.ruleForm.product_go[rowIndex].anomalous_remark = "";
-    },
-    //
-    openModal(code, btn_code) {
-      this.btn_code = btn_code;
-      this.modelId = code;
+    openModal(index) {
+      this.s_item =
+        index === -1
+          ? {}
+          : JSON.parse(JSON.stringify(this.ruleForm.product_go[index]));
+      this.index = index;
       this.showModel = true;
     },
     // 获取弹窗的值
     handleValue(e) {
-      if (e) {
-        const { numbers, reason, remark, name } = e;
-        let v = {
-          anomalous_numbers: numbers || "",
-          anomalous_reason: name || "",
-          anomalous_reason_code: reason || "", //异常原因code
-          anomalous_remark: remark || "",
-        };
-        let list = JSON.parse(JSON.stringify(this.voList));
-        list.forEach((v) => {
-          v.edit = false;
-          this.ruleForm.product_go.push(v);
-        });
-        this.voList = [];
-        this.voList.push(v);
+      const { index, item } = e;
+      if (index === -1) {
+        this.ruleForm.product_go.push(JSON.parse(JSON.stringify(item)));
+      } else {
+        const { error_num, error_code, error_remark, error_code_name, id } =
+          JSON.parse(JSON.stringify(item));
+        this.ruleForm.product_go[index].id = id;
+        this.ruleForm.product_go[index].error_num = error_num;
+        this.ruleForm.product_go[index].error_code = error_code;
+        this.ruleForm.product_go[index].error_remark = error_remark;
+        this.ruleForm.product_go[index].error_code_name = error_code_name;
       }
-      let list = JSON.parse(JSON.stringify(this.voList));
-      list.forEach((v) => {
-        v.edit = false;
-        this.ruleForm.product_go.push(v);
-      });
-      this.voList = [];
+      this.$refs.ruleForm.validateField("product_go");
     },
   },
 };

+ 8 - 11
src/views/sellOut/returnOrder/detail.vue

@@ -1,12 +1,10 @@
 <template>
-  <div class="sellReturnDetail pagePadding">
+  <div class="returnOrderDetail pagePadding">
     <div
       style="width: 100%"
       v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
     >
-      <p>sellReturnDetail页面{{ powers }}</p>
-      <p>status{{ status }}</p>
-      <p>{{ newTime }}</p>
+      <p>{{ status }}---{{ powers }}</p>
       <status-bar
         v-if="newTime !== ''"
         :newTime="newTime"
@@ -16,7 +14,7 @@
       <el-collapse v-model="activeNames">
         <el-collapse-item title="退货验收记录" name="0">
           <return-record
-            :sitem="s_sitem"
+            :sitem="sitem"
             @refresh="initData"
             :newTime="newTime"
           ></return-record>
@@ -26,7 +24,7 @@
           <return-check
             v-if="newTime != '' && status == '2'"
             :newTime="newTime"
-            :sitem="s_sitem"
+            :sitem="sitem"
             @refresh="initData"
           ></return-check>
         </el-collapse-item>
@@ -68,7 +66,7 @@ import ReturnRecord from "./components/return-record.vue";
 import ReturnCheck from "./components/returnCheck.vue";
 
 export default {
-  name: "sellReturnDetail",
+  name: "returnOrderDetail",
   mixins: [mixinPage, resToken],
   components: {
     ReturnRecord,
@@ -78,7 +76,7 @@ export default {
     powers() {
       let tran =
         this.$store.getters.btnList.find(
-          (item) => item.menu_route == "sellReturnDetail"
+          (item) => item.menu_route == "returnOrderDetail"
         ) || {};
       if (tran && tran.action && tran.action.length > 0) {
         return tran.action;
@@ -104,11 +102,10 @@ export default {
         // { id: "3", label: "待业务审核" },
         // { id: "4", label: "完成退货" },
       ],
-      s_sitem: null, //传给组件
+      sitem: null, //传给组件
       // --
       orderCode: "",
       activeNames: ["0", "1", "2", "10"],
-      sitem: null,
       status: "", //存储详情接口状态
       statusList: [
         {
@@ -181,7 +178,7 @@ export default {
       const res = await asyncRequest.detail(model);
       if (res && res.code === 0 && res.data) {
         this.status = res.data.status;
-        this.s_sitem = res.data;
+        this.sitem = res.data;
         this.orderCode =res.data.orderCode;
         this.getNewTime();
       } else if (res && res.code >= 100 && res.code <= 104) {

+ 3 - 18
src/views/sellOut/returnOrder/index.vue

@@ -3,10 +3,9 @@
     <div
       v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
     >
-      <!-- loading -->
-      powers:{{ powers }}
+      {{ powers }}
       <ex-table
-        v-loading="false"
+        v-loading="loading"
         :table="table"
         :data="tableData"
         :columns="columns"
@@ -75,20 +74,6 @@
                 </el-select>
               </el-col>
 
-              <el-col
-                :span="3"
-                style="width: 66px; float: right"
-                v-if="powers.some((item) => item == '003')"
-              >
-                <el-button
-                  @click="openModal('add', false, {})"
-                  :size="searchSize"
-                  type="success"
-                  style="float: right; margin-left: 5px"
-                >
-                  添加
-                </el-button>
-              </el-col>
 
               <el-col :span="3" style="width: 66px; float: right">
                 <el-button
@@ -169,7 +154,7 @@
           >
             <i
               class="el-icon-view tb-icon"
-              @click="routeGoto('sellReturnDetail', { id: scope.row.thNo })"
+              @click="routeGoto('returnOrderDetail', { id: scope.row.thNo })"
             ></i>
           </el-tooltip>
           <el-tooltip

+ 29 - 21
src/views/sheetOrder/zxAfterSaleOrder/components/return-record.vue

@@ -22,7 +22,9 @@
       <el-col :span="12">
         <el-form-item label="可销售数量" prop="normal">
           <el-input
-            :disabled="!(status==='0'&&powers.some((item) => item == '047'))"
+            :disabled="
+              !(status === '0' && powers.some((item) => item == '047'))
+            "
             v-model="ruleForm.normal"
             placeholder="可销售数量"
           ></el-input>
@@ -31,7 +33,9 @@
       <el-col :span="24">
         <el-form-item label="其他备注" prop="remark">
           <el-input
-            :disabled="!(status==='0'&&powers.some((item) => item == '047'))"
+            :disabled="
+              !(status === '0' && powers.some((item) => item == '047'))
+            "
             type="textarea"
             maxlength="250"
             show-word-limit
@@ -63,7 +67,7 @@
                 fixed="right"
                 label="操作"
                 width="80"
-                v-if="status==='0'&&powers.some((item) => item == '047')"
+                v-if="status === '0' && powers.some((item) => item == '047')"
               >
                 <template slot="header" slot-scope="scope">
                   <!-- v-if="status == '1' || status == '0'" -->
@@ -116,15 +120,15 @@
       <el-col
         :span="24"
         style="text-align: right; margin: -5px 0 20px 0"
-        v-if="status==='0'&&powers.some((item) => item == '047')"
+        v-if="status === '0' && powers.some((item) => item == '047')"
       >
         <el-button type="primary" class="fr" :size="'mini'" @click="submitForm"
           >保 存
         </el-button>
       </el-col>
     </el-row>
-    <add-edit-model
-      :id="modelId"
+    <abnormal-condition-modal
+      :index="index"
       :sitem="s_item"
       :show-model="showModel"
       @refresh="handleValue"
@@ -136,13 +140,12 @@
 import asyncRequest from "@/apis/service/sellOut/returnOrder";
 import resToken from "@/mixins/resToken";
 import { isnumber } from "@/utils/validate";
-import addEdit from "./addEdit";
-import addEditModel from "./addEditModel";
+import abnormalConditionModal from "@/components/abnormal-condition-modal";
 export default {
   name: "zxAfterSaleOrderDetail",
   props: ["id", "showModelThis", "newTime", "sitem"],
   mixins: [resToken],
-  components: { addEdit, addEditModel },
+  components: { abnormalConditionModal },
   data() {
     const validatenumbers = (rule, value, callback) => {
       if (value === "") {
@@ -169,7 +172,7 @@ export default {
       },
 
       btn_code: "",
-      modelId: "",
+      index: "",
       options: [],
       edit: false, //默认不能提交
       totalNumber: 0, //全局保存数量
@@ -218,9 +221,9 @@ export default {
     },
   },
 
-  mounted() {
-    this.initForm();
-  },
+  // mounted() {
+  //   this.initForm();
+  // },
   watch: {
     newTime: function (val) {
       if (val) {
@@ -247,12 +250,16 @@ export default {
           this.arr = [];
           let { child, status, normal_num, remark, return_num } = this.sitem;
           this.status = status;
-          this.arr =
-            child && child.length > 0 ? JSON.parse(JSON.stringify(child)) : [];
-          this.arr.forEach((v) => {
-            v.is_del = "0";
-            v.error_code_name=v.error_msg
-          });
+          if (child) {
+            this.arr =
+              child && child.length > 0
+                ? JSON.parse(JSON.stringify(child))
+                : [];
+            this.arr.forEach((v) => {
+              v.is_del = "0";
+              v.error_code_name = v.error_msg;
+            });
+          }
           this.ruleForm = {
             return_num: return_num || "",
             normal: normal_num || "", //可销售数量
@@ -346,7 +353,7 @@ export default {
         index === -1
           ? {}
           : JSON.parse(JSON.stringify(this.ruleForm.product_go[index]));
-      this.modelId = index;
+      this.index = index;
       this.showModel = true;
     },
     // 获取弹窗的值
@@ -355,8 +362,9 @@ export default {
       if (index === -1) {
         this.ruleForm.product_go.push(JSON.parse(JSON.stringify(item)));
       } else {
-        const { error_num, error_code, error_remark, error_code_name } =
+        const { error_num, error_code, error_remark, error_code_name, id } =
           JSON.parse(JSON.stringify(item));
+        this.ruleForm.product_go[index].id = id;
         this.ruleForm.product_go[index].error_num = error_num;
         this.ruleForm.product_go[index].error_code = error_code;
         this.ruleForm.product_go[index].error_remark = error_remark;