Browse Source

教师价格修改

秦鹏 3 years ago
parent
commit
b17b2492c4
1 changed files with 89 additions and 7 deletions
  1. 89 7
      src/views/teacher-devEntering/creadDocument.vue

+ 89 - 7
src/views/teacher-devEntering/creadDocument.vue

@@ -46,16 +46,50 @@
             ></el-input>
           </el-form-item>
           <!-- 作者 -->
-          <el-form-item :label="$t('Key227')" prop="author">
-            <!-- 多个作者请用逗号隔开 -->
+          <!-- 多个作者请用逗号隔开 -->
+
+          <!-- <el-form-item :label="$t('Key227')" prop="author">
             <el-input
               v-model="form.author"
               style="width: 500px"
               :placeholder="$t('Key553')"
               @change="authorChange"
+
+            ></el-input>
+          </el-form-item> -->
+
+          <el-form-item :label="$t('Key227')" prop="author">
+            <el-tag
+              :key="tag + i"
+              v-for="(tag, i) in dynamicTags"
+              closable
+              :disable-transitions="false"
+              @close="handleClose(i)"
+            >
+              {{ tag }}
+            </el-tag>
+            <el-input
+              class="input-new-tag"
+              v-if="inputVisible"
+              ref="saveTagInput"
+              size="small"
+              v-model="TeahcerName"
+              @change="TeahcerName = TeahcerName.trim()"
+              @keyup.enter.native="handleInputConfirm"
+              @blur="handleInputConfirm"
               maxlength="20"
               show-word-limit
-            ></el-input>
+            >
+            </el-input>
+            <el-button
+              v-else-if="!inputVisible && dynamicTags.length < 10"
+              class="button-new-tag"
+              @click="showInput"
+            >
+              {{ $t("Key151") }}
+
+              <!-- 新增教师 -->
+            </el-button>
           </el-form-item>
           <!-- 定价 -->
           <el-form-item :label="$t('Key135')" prop="price">
@@ -153,7 +187,9 @@ export default {
         institutionID: null, //当前机构id
       },
       authorList: null,
-
+      dynamicTags: [], //教师列表
+      inputVisible: false,
+      TeahcerName: "",
       loading: false,
       rules: {
         name: [{ required: true }],
@@ -170,12 +206,36 @@ export default {
     ...mapGetters(["language_type"]),
   },
   methods: {
+    handleInputConfirm() {
+      let inputValue = this.TeahcerName;
+      if (inputValue) {
+        this.dynamicTags.push(inputValue);
+      }
+      this.inputVisible = false;
+      this.TeahcerName = "";
+    },
+    // 删除教师
+    handleClose(tag) {
+      this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
+    },
+    // 新增教师
+    showInput() {
+      this.inputVisible = true;
+      this.$nextTick((_) => {
+        this.$refs.saveTagInput.$refs.input.focus();
+      });
+    },
     priceInput(e) {
       this.form.price = this.form.price.match(/^\d*(\.?\d{0,2})/g)[0] || "";
     },
     // 处理教材价格 失去焦点保留两位小数
     priceBlur() {
-      if (Object.prototype.toString.call(this.form.price*1).indexOf("Number") != -1) {
+      if (Object.prototype.toString.call(this.form.price * 1).indexOf("Number") != -1) {
+        if (this.form.price * 1 > 9999) {
+          // 可能需要提示
+          this.form.price = "";
+          return;
+        }
         this.form.price = Number(this.form.price).toFixed(2);
       }
     },
@@ -214,6 +274,11 @@ export default {
       } else {
         newauthorList.push(this.form.author);
       }
+      if (newauthorList.length > 10) {
+        // 最多只能有10个
+        this.form.author = "";
+        return;
+      }
       this.authorList = newauthorList;
     },
     changeFillId(file, fileList) {
@@ -302,7 +367,7 @@ export default {
             materialinsert({
               name: this.form.name,
               price: this.form.price,
-              teacherList: this.authorList,
+              teacherList: this.dynamicTags,
               tenantId: this.form.institutionID,
               tagList: tag,
               attachmentIdList: res.data.attachmentIdList,
@@ -341,7 +406,7 @@ export default {
               id: this.materialId,
               name: this.form.name,
               price: this.form.price,
-              teacherList: this.authorList,
+              teacherList: this.dynamicTags,
               tenantId: this.form.institutionID,
               tagList: tag,
               attachmentIdList: res.data.attachmentIdList,
@@ -380,6 +445,7 @@ export default {
           for (let key in this.form) {
             this.form[key] = res.data.result[key];
           }
+          this.dynamicTags = res.data.result.teacher;
           this.loading = false;
           this.isSubmit = true;
           this.form.fileList = JSON.parse(res.data.result.attachment);
@@ -441,6 +507,7 @@ export default {
         "Key558",
         "Key559",
         "Key605",
+        "Key151",
       ],
     });
     this.isData = true;
@@ -496,6 +563,21 @@ export default {
       padding-left: 20px;
     }
   }
+  .input-new-tag {
+    width: 90px;
+    margin-left: 10px;
+    vertical-align: bottom;
+  }
+  .el-tag + .el-tag {
+    margin-left: 10px;
+  }
+  .button-new-tag {
+    margin-left: 10px;
+    height: 32px;
+    line-height: 30px;
+    padding-top: 0;
+    padding-bottom: 0;
+  }
 }
 </style>
 <style lang="scss">