ソースを参照

更新子表单提交时没有做校验

lex 1 年間 前
コミット
f6a814a820

+ 96 - 120
src/components/VueFormMaking/components/GenerateForm.vue

@@ -1,48 +1,18 @@
 <template>
   <div>
-    <el-form
-      ref="generateForm"
-      label-suffix=":"
-      :size="data.config.size"
-      :model="models"
-      :rules="rules"
-      :label-position="data.config.labelPosition"
-      :label-width="150 + 'px'"
-    >
+    <el-form ref="generateForm" label-suffix=":" :size="data.config.size" :model="models" :rules="rules"
+      :label-position="data.config.labelPosition" :label-width="150 + 'px'">
       <template v-for="item in templateData">
         <template v-if="item.type == 'grid'">
-          <el-row
-            :key="item.key"
-            type="flex"
-            :gutter="item.options.gutter ? item.options.gutter : 0"
-            :justify="item.options.justify"
-            :align="item.options.align"
-          >
-            <el-col
-              v-for="(col, colIndex) in item.columns"
-              :key="colIndex"
-              :span="col.span"
-            >
+          <el-row :key="item.key" type="flex" :gutter="item.options.gutter ? item.options.gutter : 0"
+            :justify="item.options.justify" :align="item.options.align">
+            <el-col v-for="(col, colIndex) in item.columns" :key="colIndex" :span="col.span">
               <template v-for="citem in col.list">
-                <el-form-item
-                  v-if="citem.type == 'blank'"
-                  :key="citem.key"
-                  :label="citem.name"
-                  :prop="citem.model"
-                >
+                <el-form-item v-if="citem.type == 'blank'" :key="citem.key" :label="citem.name" :prop="citem.model">
                   <slot :name="citem.model" :model="models" />
                 </el-form-item>
-                <genetate-form-item
-                  v-else
-                  :key="citem.key"
-                  :preview="preview"
-                  :models.sync="models"
-                  :organ-list="itemOrganList"
-                  :remote="remote"
-                  :widget="citem"
-                  :data="data"
-                  :prop-value="citem.model"
-                />
+                <genetate-form-item v-else :key="citem.key" :preview="preview" :models.sync="models"
+                  :organ-list="itemOrganList" :remote="remote" :widget="citem" :data="data" :prop-value="citem.model" />
               </template>
             </el-col>
           </el-row>
@@ -56,66 +26,30 @@
         <!-- 子表单 -->
         <template v-else-if="item.type === 'subform' && !item.hidden">
           <!-- <span :key="item.key">{{ item.type }}{{ item.hidden }}---</span> -->
-          <el-form-item
-            :key="item.key"
-            :label-width="!item.options.labelWidthStatus ? '0px' : 150 + 'px'"
-            :label="!item.options.labelWidthStatus ? '' : item.name"
-          >
-            <el-table
-              :data="models[item.model]"
-              border
-              style="width: 100%"
-              :header-cell-style="{ padding: '5px 0' }"
-              size="mini"
-              :class="!preview ? 'table-subform' : ''"
-            >
+          <el-form-item :key="item.key" :label-width="!item.options.labelWidthStatus ? '0px' : 150 + 'px'"
+            :label="!item.options.labelWidthStatus ? '' : item.name">
+            <el-table :data="models[item.model]" border style="width: 100%" :header-cell-style="{ padding: '5px 0' }"
+              size="mini" :class="!preview ? 'table-subform' : ''">
               <el-table-column v-if="!preview" fixed width="50">
                 <template slot="header">
-                  <i
-                    style="font-size: 25px; color: #409eff; cursor: pointer"
-                    class="el-icon-circle-plus"
-                    @click="addSubformCol(item)"
-                  />
+                  <i style="font-size: 25px; color: #409eff; cursor: pointer" class="el-icon-circle-plus"
+                    @click="addSubformCol(item)" />
                 </template>
                 <template slot-scope="scope">
-                  <i
-                    style="font-size: 25px; color: red"
-                    class="el-icon-remove"
-                    v-if="models[item.model].length > 1"
-                    @click="delSubformCol(item, scope.$index)"
-                  />
+                  <i style="font-size: 25px; color: red" class="el-icon-remove" v-if="models[item.model].length > 1"
+                    @click="delSubformCol(item, scope.$index)" />
                 </template>
               </el-table-column>
               <template v-for="(c, i) in item.columns">
                 <div :key="i">
-                  <el-table-column
-                    v-for="v in c.list"
-                    :key="v.key"
-                    :prop="v.model"
-                    :label="v.name"
-                    min-width="250"
-                  >
+                  <el-table-column v-for="v in c.list" :key="v.key" :prop="v.model" :label="v.name" min-width="250">
                     <template slot-scope="scope">
-                      <genetate-form-item
-                        :prop-value="
-                          item.model + '.' + scope.$index + '.' + v.model
-                        "
-                        :parent-form="item.model + scope.$index"
-                        :preview="preview"
-                        :models.sync="models"
-                        :widget="v"
-                        :remote="remote"
-                        :data="data"
-                        :disabled="disabled"
-                        :fileCheck="!!fileCheckList[item.model]"
-                        :is-label="false"
-                        :organ-list="itemOrganList"
-                        :cooperation-list="cooperationList"
-                        :subform-index="scope.$index"
-                        :subform-model="item.model"
-                        @relationFormChange="formChange"
-                        @fileCheckRequired="fileCheckRequired"
-                      />
+                      <genetate-form-item :prop-value="item.model + '.' + scope.$index + '.' + v.model
+                        " :parent-form="item.model + scope.$index" :preview="preview" :models.sync="models" :widget="v"
+                        :remote="remote" :data="data" :disabled="disabled" :fileCheck="!!fileCheckList[item.model]"
+                        :is-label="false" :organ-list="itemOrganList" :cooperation-list="cooperationList"
+                        :subform-index="scope.$index" :subform-model="item.model" @relationFormChange="formChange"
+                        @fileCheckRequired="fileCheckRequired" />
                     </template>
                   </el-table-column>
                 </div>
@@ -125,19 +59,9 @@
         </template>
 
         <template v-else>
-          <genetate-form-item
-            :key="item.key"
-            :prop-value="item.model"
-            :preview="preview"
-            :models.sync="models"
-            :widget="item"
-            :remote="remote"
-            :data="data"
-            :organ-list="itemOrganList"
-            :disabled="disabled"
-            @relationFormChange="formChange"
-            @fileCheckRequired="fileCheckRequired"
-          />
+          <genetate-form-item :key="item.key" :prop-value="item.model" :preview="preview" :models.sync="models"
+            :widget="item" :remote="remote" :data="data" :organ-list="itemOrganList" :disabled="disabled"
+            @relationFormChange="formChange" @fileCheckRequired="fileCheckRequired" />
         </template>
       </template>
     </el-form>
@@ -183,7 +107,7 @@ export default {
     data: {
       deep: true,
       handler(val) {
-        console.log(val, "deep", "handler");
+        // console.log(val, "deep", "handler");
         this.generateModle(val.list);
       },
     },
@@ -210,11 +134,15 @@ export default {
     this.templateData = JSON.parse(JSON.stringify(this.data.list));
     this.generateModle(this.templateData);
     // 选项关联不支付子表单
+
     if (!this.preview) {
       let tempData = this.templateData;
       let hiddenFormList = this.getSelectValueObject(tempData);
       this.formStatus = hiddenFormList;
       this.relationFormChange();
+      // console.log(this.rules, 'this.rules')
+      // console.log(this.value, 'this.value', !this.value, this.templateData, 'templateData', this.models, 'models')
+      // 判断是否在缓存数据
       if (!this.value) {
         // 如果不是预览时,则默认给子表单添加一行数据
         tempData.forEach(async (item) => {
@@ -222,26 +150,46 @@ export default {
             await this.addSubformCol(item);
           }
         });
+      } else {
+        // 如果有缓存数据,则给subform动态添加表单校验
+        let subform = {}
+        // 判断是否有数据 - 可能存在多个子表单
+        for (let i in this.value) {
+          const index = i.indexOf('subform')
+          if (index > -1) {
+            // subform.push(this.value[index])
+            subform[i] = this.value[i] || []
+          }
+        }
+
+        for (let i in subform) {
+          // 判断是否有数据
+          if (subform[i].length > 0) {
+            const subIndex = subform[i].length
+            let selectItem = ''
+            tempData.forEach(async (item) => {
+              if (item.type === "subform" && item.model == i) {
+                // await this.addRule(item);
+                // console.log(item, 'item')
+                selectItem = item;
+              }
+            });
+
+            if (selectItem) {
+              for (let j = 0; j < subIndex; j++) {
+                this.addRule(selectItem, j)
+              }
+            }
+          }
+        }
       }
+
     } else {
       let tempData = this.templateData;
       let hiddenFormList = this.getSelectValueObject(tempData);
       this.formStatus = hiddenFormList;
       // let ids = this.getSelectValueObject(tempData, true);
       this.relationFormChange();
-
-      // const values = this.models[ids.model];
-      // let relationArray = [];
-      // ids.options &&
-      //   ids.options.options.forEach((item) => {
-      //     if (values == item.value) {
-      //       let tempRelation = item.relationOptions || [];
-      //       relationArray.push(...tempRelation);
-      //     }
-      //   });
-      // if (relationArray.length > 0) {
-      //   this.relationFormChange(relationArray);
-      // }
     }
 
     this.originRules = JSON.parse(JSON.stringify(this.rules));
@@ -268,6 +216,34 @@ export default {
       this.rules = rules;
       this.$forceUpdate();
     },
+    // 固定添加某一个数据的规则
+    addRule(item, index) {
+      for (var c of item.columns) {
+        for (var l of c.list) {
+          if (this.rules[item.model] === undefined) {
+            this.rules[item.model] = [];
+          }
+          if (
+            this.rules[item.model][index] === undefined
+          ) {
+            this.rules[item.model][index] = {};
+          }
+          this.rules[item.model][index][l.model] = [
+            ...l.rules.map((item) => {
+              if (item.pattern) {
+                return { ...item, pattern: eval(item.pattern) };
+              } else {
+                if (this.fileCheck) {
+                  item.required = false;
+                }
+                return { ...item };
+              }
+            }),
+          ];
+        }
+      }
+      this.originRules = JSON.parse(JSON.stringify(this.rules));
+    },
     addSubformCol(item) {
       var subformFields = {};
       for (var c of item.columns) {
@@ -275,7 +251,7 @@ export default {
           if (l.options !== null && l.options !== undefined) {
             subformFields[l.model] =
               l.options.defaultValue !== undefined &&
-              l.options.defaultValue !== null
+                l.options.defaultValue !== null
                 ? l.options.defaultValue
                 : "";
           } else {
@@ -396,7 +372,7 @@ export default {
     },
     async formChange(value, options) {
       // new Promise(function(resolve, reject) {)
-      console.log(value, options);
+      // console.log(value, options);
       await this.formInit(options);
       let tempData = JSON.parse(JSON.stringify(this.templateData));
       tempData.forEach(async (item) => {
@@ -460,8 +436,8 @@ export default {
                 genList[i].options.defaultType === "String"
                   ? ""
                   : genList[i].options.defaultType === "Object"
-                  ? {}
-                  : []
+                    ? {}
+                    : []
               );
             }
             if (genList[i].type === "subform") {

+ 137 - 351
src/components/VueFormMaking/components/GenerateFormItem.vue

@@ -1,27 +1,16 @@
 <template>
-  <el-form-item
-    v-if="showStatus && hidden"
-    :label-width="
-      isLabel === false || !widget.options.labelWidthStatus ? '0px' : 150 + 'px'
-    "
-    :label="
-      isLabel === false ||
-      widget.type === 'divider' ||
-      !widget.options.labelWidthStatus
-        ? ''
-        : widget.name
-    "
-    :key="propValue"
-    :prop="propValue"
-    :class="[parentForm, widget.type == 'text' && 'dataModelText']"
-    :style="subformIndex !== undefined ? { 'margin-bottom': '0' } : {}"
-  >
+  <el-form-item v-if="showStatus && hidden" :label-width="isLabel === false || !widget.options.labelWidthStatus ? '0px' : 150 + 'px'
+    " :label="isLabel === false ||
+    widget.type === 'divider' ||
+    !widget.options.labelWidthStatus
+    ? ''
+    : widget.name
+    " :key="propValue" :prop="propValue" :class="[parentForm, widget.type == 'text' && 'dataModelText']"
+    :style="subformIndex !== undefined ? { 'margin-bottom': '0' } : {}">
     <template v-if="preview">
       <template v-if="widget.type === 'color'">
-        <div
-          style="width: 32px; height: 20px; margin-top: 6px; border-radius: 3px"
-          :style="{ 'background-color': dataModel }"
-        />
+        <div style="width: 32px; height: 20px; margin-top: 6px; border-radius: 3px"
+          :style="{ 'background-color': dataModel }" />
       </template>
       <template v-else-if="widget.type == 'switch'">
         <el-switch v-model="dataModel" :disabled="true" />
@@ -31,47 +20,18 @@
       </template>
 
       <template v-else-if="widget.type == 'file'">
-        <div
-          v-for="(uploadUrlItem, uploadUrlIndex) of dataModel"
-          :key="uploadUrlIndex"
-        >
+        <div v-for="(uploadUrlItem, uploadUrlIndex) of dataModel" :key="uploadUrlIndex">
           <i style="color: #909399" class="el-icon-document" />
           <span>{{ uploadUrlItem.name || uploadUrlItem.url }}</span>
-          <el-button
-            round
-            size="mini"
-            @click="onDownload(uploadUrlItem, 'download')"
-            >下载</el-button
-          >
-          <el-button
-            round
-            type="primary"
-            @click="onDownload(uploadUrlItem)"
-            v-if="
-              checkFileSuffix(uploadUrlItem.url) &&
-              !isCheckImage(uploadUrlItem.url)
-            "
-            size="mini"
-            >预览</el-button
-          >
-          <div
-            v-if="isCheckImage(uploadUrlItem.url)"
-            style="display: inline-flex; position: relative"
-          >
-            <el-button
-              style="position: absolute; left: 0; top: 0"
-              round
-              type="primary"
-              @click="onDownload(uploadUrlItem)"
-              v-if="checkFileSuffix(uploadUrlItem.url)"
-              size="mini"
-              >预览</el-button
-            >
-            <el-image
-              style="width: 56px; height: 28px; opacity: 0"
-              :src="uploadUrlItem.url"
-              :preview-src-list="[uploadUrlItem.url]"
-            >
+          <el-button round size="mini" @click="onDownload(uploadUrlItem, 'download')">下载</el-button>
+          <el-button round type="primary" @click="onDownload(uploadUrlItem)" v-if="checkFileSuffix(uploadUrlItem.url) &&
+            !isCheckImage(uploadUrlItem.url)
+            " size="mini">预览</el-button>
+          <div v-if="isCheckImage(uploadUrlItem.url)" style="display: inline-flex; position: relative">
+            <el-button style="position: absolute; left: 0; top: 0" round type="primary" @click="onDownload(uploadUrlItem)"
+              v-if="checkFileSuffix(uploadUrlItem.url)" size="mini">预览</el-button>
+            <el-image style="width: 56px; height: 28px; opacity: 0" :src="uploadUrlItem.url"
+              :preview-src-list="[uploadUrlItem.url]">
             </el-image>
           </div>
           <!-- <a :href="uploadUrlItem.url" target="_blank">{{ uploadUrlItem.name || uploadUrlItem.url }}</a> -->
@@ -79,61 +39,34 @@
       </template>
 
       <template v-else-if="widget.type == 'imgupload'">
-        <fm-upload
-          v-model="dataModel"
-          :style="{ width: widget.options.width }"
-          :width="widget.options.size.width"
-          :height="widget.options.size.height"
-          :preview="preview"
-        />
+        <fm-upload v-model="dataModel" :style="{ width: widget.options.width }" :width="widget.options.size.width"
+          :height="widget.options.size.height" :preview="preview" />
       </template>
       <template v-else-if="widget.type == 'rate'">
-        <el-rate
-          v-model="dataModel"
-          :max="widget.options.max"
-          :disabled="true"
-          :allow-half="widget.options.allowHalf"
-        />
+        <el-rate v-model="dataModel" :max="widget.options.max" :disabled="true" :allow-half="widget.options.allowHalf" />
       </template>
       <template v-else-if="widget.type === 'divider'">
-        <el-divider
-          :direction="widget.options.direction"
-          :content-position="widget.options.content_position"
-        >
-          <span
-            :style="{
-              'font-size': widget.options.font_size,
-              'font-family': widget.options.font_family,
-              'font-weight': widget.options.font_weight,
-              color: widget.options.font_color,
-            }"
-          >
+        <el-divider :direction="widget.options.direction" :content-position="widget.options.content_position">
+          <span :style="{
+            'font-size': widget.options.font_size,
+            'font-family': widget.options.font_family,
+            'font-weight': widget.options.font_weight,
+            color: widget.options.font_color,
+          }">
             {{ widget.options.defaultValue }}
           </span>
         </el-divider>
       </template>
-      <template
-        v-else-if="widget.type === 'input' && widget.options.showPassword"
-      >
-        <input
-          :value="dataModel"
-          type="password"
-          style="border: none; background-color: #ffffff; color: #303133"
-          disabled="disabled"
-        />
+      <template v-else-if="widget.type === 'input' && widget.options.showPassword">
+        <input :value="dataModel" type="password" style="border: none; background-color: #ffffff; color: #303133"
+          disabled="disabled" />
       </template>
       <template v-else-if="widget.type === 'cascader'">
-        <el-cascader
-          v-model="dataModel"
-          class="preview-cascader-class"
-          :disabled="true"
-          :show-all-levels="widget.options.showAllLevels"
-          :options="
-            widget.options.remote
-              ? widget.options.remoteOptions
-              : widget.options.options
-          "
-        />
+        <el-cascader v-model="dataModel" class="preview-cascader-class" :disabled="true"
+          :show-all-levels="widget.options.showAllLevels" :options="widget.options.remote
+            ? widget.options.remoteOptions
+            : widget.options.options
+            " />
       </template>
       <template v-else-if="widget.type === 'textarea'">
         <span v-html="dataFormatBr(dataModel)"></span>
@@ -154,68 +87,34 @@
     </template>
     <template v-else>
       <template v-if="widget.type === 'input'">
-        <el-input
-          v-if="
-            widget.options.dataType === 'number' ||
-            widget.options.dataType === 'integer' ||
-            widget.options.dataType === 'float'
-          "
-          v-model="dataModel"
-          :type="widget.options.dataType"
-          @input="onInputChangeNumber($event)"
-          :placeholder="widget.options.placeholder"
-          :style="{ width: widget.options.width }"
-          :disabled="widget.options.disabled"
-          :show-password="widget.options.showPassword"
-        />
-        <el-input
-          v-else
-          v-model="dataModel"
-          :type="widget.options.dataType"
-          :disabled="widget.options.disabled"
-          :placeholder="widget.options.placeholder"
-          :style="{ width: widget.options.width }"
-          :show-password="widget.options.showPassword"
-        />
+        <el-input v-if="widget.options.dataType === 'number' ||
+          widget.options.dataType === 'integer' ||
+          widget.options.dataType === 'float'
+          " v-model="dataModel" :type="widget.options.dataType" @input="onInputChangeNumber($event)"
+          :placeholder="widget.options.placeholder" :style="{ width: widget.options.width }"
+          :disabled="widget.options.disabled" :show-password="widget.options.showPassword" />
+        <el-input v-else v-model="dataModel" :type="widget.options.dataType" :disabled="widget.options.disabled"
+          :placeholder="widget.options.placeholder" :style="{ width: widget.options.width }"
+          :show-password="widget.options.showPassword" />
       </template>
 
       <template v-if="widget.type === 'textarea'">
-        <el-input
-          v-model="dataModel"
-          type="textarea"
-          :rows="5"
-          :disabled="widget.options.disabled"
-          :placeholder="widget.options.placeholder"
-          :style="{ width: widget.options.width }"
-        />
+        <el-input v-model="dataModel" type="textarea" :rows="5" :disabled="widget.options.disabled"
+          :placeholder="widget.options.placeholder" :style="{ width: widget.options.width }" />
       </template>
 
       <template v-if="widget.type === 'number'">
-        <el-input-number
-          v-model="dataModel"
-          :style="{ width: widget.options.width }"
-          :step="widget.options.step"
-          controls-position="right"
-          :disabled="widget.options.disabled"
-        />
+        <el-input-number v-model="dataModel" :style="{ width: widget.options.width }" :step="widget.options.step"
+          controls-position="right" :disabled="widget.options.disabled" />
       </template>
 
       <template v-if="widget.type === 'radio'">
-        <el-radio-group
-          v-model="dataModel"
-          :style="{ width: widget.options.width }"
-          :disabled="widget.options.disabled"
-        >
-          <el-radio
-            v-for="(item, index) in widget.options.remote
+        <el-radio-group v-model="dataModel" :style="{ width: widget.options.width }" :disabled="widget.options.disabled">
+          <el-radio v-for="(item, index) in widget.options.remote
               ? widget.options.remoteOptions
-              : widget.options.options"
-            :key="index"
-            :style="{
-              display: widget.options.inline ? 'inline-block' : 'block',
-            }"
-            :label="item.value"
-          >
+              : widget.options.options" :key="index" :style="{
+      display: widget.options.inline ? 'inline-block' : 'block',
+    }" :label="item.value">
             <template v-if="widget.options.remote">{{ item.label }}</template>
             <template v-else>{{
               widget.options.showLabel ? item.label : item.value
@@ -225,21 +124,13 @@
       </template>
 
       <template v-if="widget.type === 'checkbox'">
-        <el-checkbox-group
-          v-model="dataModel"
-          :style="{ width: widget.options.width }"
-          :disabled="widget.options.disabled"
-        >
-          <el-checkbox
-            v-for="(item, index) in widget.options.remote
+        <el-checkbox-group v-model="dataModel" :style="{ width: widget.options.width }"
+          :disabled="widget.options.disabled">
+          <el-checkbox v-for="(item, index) in widget.options.remote
               ? widget.options.remoteOptions
-              : widget.options.options"
-            :key="index"
-            :style="{
-              display: widget.options.inline ? 'inline-block' : 'block',
-            }"
-            :label="item.value"
-          >
+              : widget.options.options" :key="index" :style="{
+      display: widget.options.inline ? 'inline-block' : 'block',
+    }" :label="item.value">
             <template v-if="widget.options.remote">{{ item.label }}</template>
             <template v-else>{{
               widget.options.showLabel ? item.label : item.value
@@ -249,122 +140,56 @@
       </template>
 
       <template v-if="widget.type === 'time'">
-        <el-time-picker
-          v-model="dataModel"
-          :is-range="widget.options.isRange"
-          :placeholder="widget.options.placeholder"
-          :start-placeholder="widget.options.startPlaceholder"
-          :end-placeholder="widget.options.endPlaceholder"
-          :readonly="widget.options.readonly"
-          :disabled="widget.options.disabled"
-          :editable="widget.options.editable"
-          :clearable="widget.options.clearable"
-          :arrow-control="widget.options.arrowControl"
-          :value-format="widget.options.format"
-          :style="{ width: widget.options.width }"
-        />
+        <el-time-picker v-model="dataModel" :is-range="widget.options.isRange" :placeholder="widget.options.placeholder"
+          :start-placeholder="widget.options.startPlaceholder" :end-placeholder="widget.options.endPlaceholder"
+          :readonly="widget.options.readonly" :disabled="widget.options.disabled" :editable="widget.options.editable"
+          :clearable="widget.options.clearable" :arrow-control="widget.options.arrowControl"
+          :value-format="widget.options.format" :style="{ width: widget.options.width }" />
       </template>
 
       <template v-if="widget.type == 'date'">
-        <el-date-picker
-          v-model="dataModel"
-          :type="widget.options.type"
-          :placeholder="widget.options.placeholder"
-          :start-placeholder="widget.options.startPlaceholder"
-          :end-placeholder="widget.options.endPlaceholder"
-          :readonly="widget.options.readonly"
-          :disabled="widget.options.disabled"
-          :editable="widget.options.editable"
-          :clearable="widget.options.clearable"
-          :value-format="
-            widget.options.timestamp ? 'timestamp' : widget.options.format
-          "
-          :format="widget.options.format"
-          :style="{ width: widget.options.width }"
-        />
+        <el-date-picker v-model="dataModel" :type="widget.options.type" :placeholder="widget.options.placeholder"
+          :start-placeholder="widget.options.startPlaceholder" :end-placeholder="widget.options.endPlaceholder"
+          :readonly="widget.options.readonly" :disabled="widget.options.disabled" :editable="widget.options.editable"
+          :clearable="widget.options.clearable" :value-format="widget.options.timestamp ? 'timestamp' : widget.options.format
+            " :format="widget.options.format" :style="{ width: widget.options.width }" />
       </template>
 
       <template v-if="widget.type == 'rate'">
-        <el-rate
-          v-model="dataModel"
-          :max="widget.options.max"
-          :disabled="widget.options.disabled"
-          :allow-half="widget.options.allowHalf"
-        />
+        <el-rate v-model="dataModel" :max="widget.options.max" :disabled="widget.options.disabled"
+          :allow-half="widget.options.allowHalf" />
       </template>
 
       <template v-if="widget.type === 'color'">
-        <el-color-picker
-          v-model="dataModel"
-          :disabled="widget.options.disabled"
-          :show-alpha="widget.options.showAlpha"
-        />
+        <el-color-picker v-model="dataModel" :disabled="widget.options.disabled" :show-alpha="widget.options.showAlpha" />
       </template>
 
       <template v-if="widget.type === 'select'">
-        <el-select
-          v-model="dataModel"
-          :disabled="widget.options.disabled"
-          :multiple="widget.options.multiple"
-          :clearable="widget.options.clearable"
-          :placeholder="widget.options.placeholder"
-          :style="{ width: widget.options.width }"
-          filterable
-          @change="onChangeSelect"
-        >
-          <el-option
-            v-for="item in widget.options.remote
-              ? widget.options.remoteOptions
-              : widget.options.options"
-            :key="item.value"
-            :value="item.value"
-            :label="
-              widget.options.showLabel || widget.options.remote
-                ? item.label
-                : item.value
-            "
-          />
+        <el-select v-model="dataModel" :disabled="widget.options.disabled" :multiple="widget.options.multiple"
+          :clearable="widget.options.clearable" :placeholder="widget.options.placeholder"
+          :style="{ width: widget.options.width }" filterable @change="onChangeSelect">
+          <el-option v-for="item in widget.options.remote
+            ? widget.options.remoteOptions
+            : widget.options.options" :key="item.value" :value="item.value" :label="widget.options.showLabel || widget.options.remote
+    ? item.label
+    : item.value
+    " />
         </el-select>
       </template>
 
       <template v-if="widget.type === 'organ'">
-        <el-select
-          v-model="dataModel"
-          :disabled="widget.options.disabled"
-          :multiple="widget.options.multiple"
-          clearable
-          filterable
-          :placeholder="widget.options.placeholder"
-          :style="{ width: widget.options.width }"
-          :name="widget.model"
-        >
-          <el-option
-            v-for="item in organList"
-            :key="item.id"
-            :value="item.id"
-            :label="item.name"
-          />
+        <el-select v-model="dataModel" :disabled="widget.options.disabled" :multiple="widget.options.multiple" clearable
+          filterable :placeholder="widget.options.placeholder" :style="{ width: widget.options.width }"
+          :name="widget.model">
+          <el-option v-for="item in organList" :key="item.id" :value="item.id" :label="item.name" />
         </el-select>
       </template>
 
       <template v-if="widget.type === 'school'">
-        <el-select
-          v-model="dataModel"
-          :disabled="widget.options.disabled"
-          :multiple="widget.options.multiple"
-          clearable
-          :placeholder="widget.options.placeholder"
-          :style="{ width: widget.options.width }"
-          filterable
-          :loading="selectLoading"
-          @visible-change="onGetSchoolList"
-        >
-          <el-option
-            v-for="item in cooperationList"
-            :key="item.id"
-            :value="item.id"
-            :label="item.name"
-          />
+        <el-select v-model="dataModel" :disabled="widget.options.disabled" :multiple="widget.options.multiple" clearable
+          :placeholder="widget.options.placeholder" :style="{ width: widget.options.width }" filterable
+          :loading="selectLoading" @visible-change="onGetSchoolList">
+          <el-option v-for="item in cooperationList" :key="item.id" :value="item.id" :label="item.name" />
         </el-select>
       </template>
 
@@ -373,96 +198,55 @@
       </template>
 
       <template v-if="widget.type == 'slider'">
-        <el-slider
-          v-model="dataModel"
-          :min="widget.options.min"
-          :max="widget.options.max"
-          :disabled="widget.options.disabled"
-          :step="widget.options.step"
-          :show-input="widget.options.showInput"
-          :range="widget.options.range"
-          :style="{ width: widget.options.width }"
-        />
+        <el-slider v-model="dataModel" :min="widget.options.min" :max="widget.options.max"
+          :disabled="widget.options.disabled" :step="widget.options.step" :show-input="widget.options.showInput"
+          :range="widget.options.range" :style="{ width: widget.options.width }" />
       </template>
 
       <template v-if="widget.type == 'imgupload'">
-        <fm-upload
-          v-model="dataModel"
-          :disabled="widget.options.disabled"
-          :style="{ width: widget.options.width }"
-          :width="widget.options.size.width"
-          :height="widget.options.size.height"
-          :token="widget.options.token"
-          :domain="widget.options.domain"
-          :multiple="widget.options.multiple"
-          :length="widget.options.length"
-          :is-qiniu="widget.options.isQiniu"
-          :is-delete="widget.options.isDelete"
-          :min="widget.options.min"
-          :is-edit="widget.options.isEdit"
-          :action="widget.options.action"
-        />
+        <fm-upload v-model="dataModel" :disabled="widget.options.disabled" :style="{ width: widget.options.width }"
+          :width="widget.options.size.width" :height="widget.options.size.height" :token="widget.options.token"
+          :domain="widget.options.domain" :multiple="widget.options.multiple" :length="widget.options.length"
+          :is-qiniu="widget.options.isQiniu" :is-delete="widget.options.isDelete" :min="widget.options.min"
+          :is-edit="widget.options.isEdit" :action="widget.options.action" />
       </template>
 
       <template v-if="widget.type == 'file'">
-        <FileUpload
-          :element="widget"
-          :data-model="dataModel"
-          @fileList="fileList"
-        />
+        <FileUpload :element="widget" :data-model="dataModel" @fileList="fileList" />
       </template>
 
       <template v-if="widget.type === 'editor'">
-        <vue-editor
-          v-model="dataModel"
-          :disabled="widget.options.disabled"
-          :style="{ width: widget.options.width }"
-        />
+        <vue-editor v-model="dataModel" :disabled="widget.options.disabled" :style="{ width: widget.options.width }" />
       </template>
 
       <template v-if="widget.type === 'cascader'">
-        <el-cascader
-          v-model="dataModel"
-          :disabled="widget.options.disabled"
-          :show-all-levels="widget.options.showAllLevels"
-          :clearable="widget.options.clearable"
-          :placeholder="widget.options.placeholder"
-          :style="{ width: widget.options.width }"
-          :options="
-            widget.options.remote
-              ? widget.options.remoteOptions
-              : widget.options.options
-          "
-        />
+        <el-cascader v-model="dataModel" :disabled="widget.options.disabled"
+          :show-all-levels="widget.options.showAllLevels" :clearable="widget.options.clearable"
+          :placeholder="widget.options.placeholder" :style="{ width: widget.options.width }" :options="widget.options.remote
+            ? widget.options.remoteOptions
+            : widget.options.options
+            " />
       </template>
 
       <template v-if="widget.type === 'text'">
         <!-- color: widget.options.font_color, -->
-        <span
-          :style="{
-            'font-size': widget.options.font_size,
-            'font-family': widget.options.font_family,
-            'font-weight': widget.options.font_weight,
-          }"
-          class="dataModelText"
-        >
+        <span :style="{
+          'font-size': widget.options.font_size,
+          'font-family': widget.options.font_family,
+          'font-weight': widget.options.font_weight,
+        }" class="dataModelText">
           {{ widget.options.defaultValue }}
         </span>
       </template>
 
       <template v-if="widget.type === 'divider'">
-        <el-divider
-          :direction="widget.options.direction"
-          :content-position="widget.options.content_position"
-        >
-          <span
-            :style="{
-              'font-size': widget.options.font_size,
-              'font-family': widget.options.font_family,
-              'font-weight': widget.options.font_weight,
-              color: widget.options.font_color,
-            }"
-          >
+        <el-divider :direction="widget.options.direction" :content-position="widget.options.content_position">
+          <span :style="{
+            'font-size': widget.options.font_size,
+            'font-family': widget.options.font_family,
+            'font-weight': widget.options.font_weight,
+            color: widget.options.font_color,
+          }">
             {{ widget.options.defaultValue }}
           </span>
         </el-divider>
@@ -515,8 +299,8 @@ export default {
         this.subformIndex === undefined
           ? this.models[this.widget.model]
           : this.models[this.subformModel][this.subformIndex][
-              this.widget.model
-            ],
+          this.widget.model
+          ],
       dataModelStr: null,
       tableData: [],
       cooperationList: [],
@@ -526,7 +310,7 @@ export default {
   },
   computed: {
     hidden() {
-      console.log(this.subformModel, this.widget.hidden);
+      // console.log(this.subformModel, this.widget.hidden);
       return this.subformModel ? true : !this.widget.hidden;
     },
   },
@@ -560,6 +344,7 @@ export default {
       deep: true,
       async handler(val) {
         // console.log(val, 'show')
+        // console.log(this.widget, "12121", this.dataModel, this.subformIndex, ' subformIndex', this.models, this.subformModel);
         if (val.status === undefined && val.status === null) {
           if (this.subformIndex === undefined) {
             this.dataModel = val[this.widget.model];
@@ -589,7 +374,8 @@ export default {
   },
   created() {
     // 判断当前元素是否是分部表单()
-    // console.log(this.widget, 'widget subform')
+    // console.log(this.widget, 'widget subform', this.data, '121212111111')
+
     if (this.widget.type == "organ" && this.preview) {
       let tempStr = null;
       this.organList.forEach((item) => {
@@ -648,18 +434,21 @@ export default {
     this.handleDisplayVerifiy();
   },
   mounted() {
-    // console.log(this.widget, "12121", this.dataModel);
+    // console.log(this.widget, "12121", this.dataModel, this.subformIndex, ' subformIndex', this.models, this.subformModel);
+    // 判断是下拉菜单,并且有关联属性
     if (this.widget.type == "select" && this.widget.options.relationStatus) {
-      console.log(true, "false");
+      // console.log(true, "false");
       this.onChangeSelect();
     }
+
+
   },
   methods: {
     isCheckImage(file) {
       const urlArr = file.split(".");
       const suffix = urlArr[urlArr.length - 1];
       const imgSuffix = ["png", "jpg", "jpeg", "gif", "ico"];
-      console.log(imgSuffix.includes(suffix), "11");
+      // console.log(imgSuffix.includes(suffix), "11");
       return imgSuffix.includes(suffix);
     },
     // 获取学校列表
@@ -794,7 +583,7 @@ export default {
             }
           }
         });
-      console.log(relationArray, "111", this.dataModel, this.widget.options);
+      // console.log(relationArray, "111", this.dataModel, this.widget.options);
       // if (relationArray.length > 0) {
       this.$emit("relationFormChange", relationArray, allArray);
       // }
@@ -827,7 +616,7 @@ export default {
       if (this.subformModel) {
         organId =
           this.models[this.subformModel][this.subformIndex][
-            this.widget.options.displayRelation
+          this.widget.options.displayRelation
           ];
       } else {
         organId = this.models[this.widget.options.displayRelation];
@@ -937,7 +726,7 @@ export default {
 </script>
 
 <style>
-.previewEditorDiv > p {
+.previewEditorDiv>p {
   margin: 0;
 }
 
@@ -947,17 +736,14 @@ export default {
   color: #303133;
 }
 
-.preview-cascader-class
-  .el-input.is-disabled
-  .el-input__suffix
-  .el-input__suffix-inner
-  .el-input__icon.el-icon-arrow-down:before {
+.preview-cascader-class .el-input.is-disabled .el-input__suffix .el-input__suffix-inner .el-input__icon.el-icon-arrow-down:before {
   content: "";
 }
 
 .dataModelText {
   color: #e7af84;
 }
+
 .dataModelText .el-form-item__label {
   color: #e7af84 !important;
 }

+ 1 - 1
src/utils/request.js

@@ -9,7 +9,7 @@ import { getToken } from "@/utils/auth";
 const service = axios.create({
   baseURL: "", // url = base url + request url
   // withCredentials: true, // send cookies when cross-domain requests
-  timeout: 10000, // request timeout
+  timeout: 20000, // request timeout
 });
 
 // request interceptor

+ 97 - 106
src/views/process/list/create.vue

@@ -5,17 +5,8 @@
         <span>公共信息</span>
       </div>
       <div class="text item">
-        <el-form
-          ref="ruleForm"
-          :model="ruleForm"
-          :rules="rules"
-          label-width="150px"
-        >
-          <el-form-item
-            label="优先级:"
-            prop="priority"
-            style="margin-bottom: 0"
-          >
+        <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="150px">
+          <el-form-item label="优先级:" prop="priority" style="margin-bottom: 0">
             <el-radio-group v-model="ruleForm.priority" size="small">
               <el-radio :label="1">一般</el-radio>
               <el-radio :label="2">紧急</el-radio>
@@ -23,23 +14,13 @@
             </el-radio-group>
           </el-form-item>
 
-          <el-form-item
-            label="申请部门:"
-            prop="deptId"
-            style="margin-bottom: 0"
-          >
+          <el-form-item label="申请部门:" prop="deptId" style="margin-bottom: 0">
             <el-select v-model="ruleForm.deptId" size="small" clearable>
-              <el-option
-                v-for="(item, index) in deptList"
-                :label="item.deptName"
-                :value="item.deptId"
-                :key="index"
-              ></el-option>
+              <el-option v-for="(item, index) in deptList" :label="item.deptName" :value="item.deptId"
+                :key="index"></el-option>
             </el-select>
             <span v-if="!socialId && currentNode.id">(未设置社保部门)</span>
-            <span v-if="ruleForm.deptId && socialId != ruleForm.deptId"
-              >(该部门非社保部门)</span
-            >
+            <span v-if="ruleForm.deptId && socialId != ruleForm.deptId">(该部门非社保部门)</span>
           </el-form-item>
         </el-form>
       </div>
@@ -51,45 +32,26 @@
       </div>
       <div class="text item">
         <template v-for="(tplItem, tplIndex) in processStructureValue.tpls">
-          <fm-generate-form
-            v-show="
-              currentNode.hideTpls === undefined ||
-              currentNode.hideTpls === null ||
-              currentNode.hideTpls.indexOf(tplItem.id) === -1
-            "
-            :key="tplIndex"
-            :ref="'generateForm-' + tplItem.id"
-            :preview="
-              currentNode.hideTpls === undefined ||
-              currentNode.hideTpls === null ||
-              currentNode.hideTpls.indexOf(tplItem.id) === -1
-                ? false
-                : true
-            "
-            :remote="remoteFunc"
-            :data="tplItem.form_structure"
-            :value="tplItem.form_data"
-            :disabled="
-              currentNode.readonlyTpls === undefined ||
-              currentNode.readonlyTpls === null ||
-              currentNode.readonlyTpls.indexOf(tplItem.id) === -1
-                ? null
-                : true
-            "
-            :organ-list="organList"
-          />
+          <fm-generate-form v-show="currentNode.hideTpls === undefined ||
+            currentNode.hideTpls === null ||
+            currentNode.hideTpls.indexOf(tplItem.id) === -1
+            " :key="tplIndex" :ref="'generateForm-' + tplItem.id" :preview="currentNode.hideTpls === undefined ||
+    currentNode.hideTpls === null ||
+    currentNode.hideTpls.indexOf(tplItem.id) === -1
+    ? false
+    : true
+    " :remote="remoteFunc" :data="tplItem.form_structure" :value="tplItem.form_data" :disabled="currentNode.readonlyTpls === undefined ||
+    currentNode.readonlyTpls === null ||
+    currentNode.readonlyTpls.indexOf(tplItem.id) === -1
+    ? null
+    : true
+    " :organ-list="organList" />
         </template>
       </div>
       <hr style="background-color: #d9d9d9; border: 0; height: 1px" />
       <div class="text item" style="text-align: center; margin-top: 18px">
-        <el-button
-          v-for="(item, index) in btn_group"
-          :key="index"
-          :type="item.className"
-          :disabled="submitDisabled"
-          @click="submitAction(item.target)"
-          >提交</el-button
-        >
+        <el-button v-for="(item, index) in btn_group" :key="index" :type="item.className" :disabled="submitDisabled"
+          @click="submitAction(item.target)">提交</el-button>
         <!-- <el-button type="default" @click="onGetFormData"> 获取数据 </el-button> -->
       </div>
     </el-card>
@@ -170,6 +132,7 @@ export default {
     this.searchs = new Searchs("process" + processId);
     const getSearch = this.searchs.get();
     this.cacheFormData = getSearch || [];
+    console.log(getSearch, 'getSearch')
 
     await this.getUserInfo();
     await this.getAllOrgan();
@@ -225,13 +188,9 @@ export default {
     },
     async getAllOrgan() {
       // 获取分部
-      // if (this.userType.indexOf("SYSTEM") != -1) {
       await queryAllToOrgan({ tenantId: this.tenantId }).then((res) => {
         if (res.code == 200) {
           const result = res.data;
-          // [
-          //   36, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 54, 55, 56,
-          // ];
           const processId = this.$route.query.processId;
           let filterOrganId = [];
           if ([40, 41, 45, 46, 47].includes(processId)) {
@@ -253,27 +212,6 @@ export default {
           this.organList = tempOrgan;
         }
       });
-      // } else {
-      //   await queryTeacherOrgan({ tenantId: this.tenantId }).then((res) => {
-      //     if (res.code == 200) {
-      //       const result = res.data;
-      //       const filterOrganId = [
-      //         36, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 54, 55, 56,
-      //       ];
-      //       let tempOrgan = [];
-      //       // 过滤不会显示的分部
-      //       result.forEach((item) => {
-      //         if (!filterOrganId.includes(item.key)) {
-      //           tempOrgan.push({
-      //             id: item.key,
-      //             name: item.value,
-      //           });
-      //         }
-      //       });
-      //       this.organList = tempOrgan;
-      //     }
-      //   });
-      // }
     },
     async getProcessNodeList() {
       const processId = this.$route.query.processId;
@@ -285,10 +223,8 @@ export default {
         userId: this.userId,
       }).then((response) => {
         let tempData = response.data.tpls;
-        // console.log(response);
         // 获取对应模板中,下拉框的key, value
         let selectList = this.getSelectValueObject(tempData);
-        // console.log(selectList);
 
         // 获取对应模板中,需要隐藏的字段
         let hiddenFormList = this.getSelectValueObject(
@@ -296,10 +232,49 @@ export default {
           "hiddenForm",
           selectList
         );
+        console.log(hiddenFormList, 'hiddenFormList', tempData)
+
+        // 获取对应缓存
+        const responseData = response.data;
+        // let formCatchData = ''
+        for (let i in responseData.tpls) {
+          const findItem = this.cacheFormData.find(
+            (item) => item.tplId == responseData.tpls[i].id
+          );
+
+          if (findItem) {
+            // formCatchData = JSON.parse(
+            //   JSON.stringify(findItem.formData)
+            // );
+            responseData.tpls[i].form_data = JSON.parse(
+              JSON.stringify(findItem.formData)
+            );
+          } else {
+            // formCatchData = '';
+            responseData.tpls[i].form_data = "";
+          }
+        }
+
+        // 获取需要显示的表单
+        // let getShowForm = [] // 显示表单显示
+        // tempData.forEach((temp, index) => {
+        //   let tempList = temp.form_structure.list || [];
+        //   tempList.forEach((item) => {
+        //     const currentItem = formCatchData ? formCatchData[item.model] : ''
+        //     if (item.type == 'select' && currentItem && item.options.relationStatus) {
+        //       const selectChioce = item.options.options ? item.options.options.find(v => v.value == currentItem) : ''
+        //       // 判断是否有多个select
+        //       getShowForm.push(selectChioce ? selectChioce.relationOptions : [])
+        //     }
+        //   })
+        // })
+
+
 
         tempData.forEach((temp, index) => {
           let tempList = temp.form_structure.list || [];
           tempList.forEach((item) => {
+            // 设置默认显示和隐藏的表单
             if (hiddenFormList[index].length > 0) {
               if (item.type != "text" && !item.options.relationStatus) {
                 item.hidden = true;
@@ -339,23 +314,18 @@ export default {
               });
               item.hidden = subFormStatus;
             }
+
+
+            // if (getShowForm && getShowForm.length > 0) {
+            //   const findIndex = getShowForm.findIndex(v => v == item.model)
+            //   console.log(findIndex, 'findIndex')
+            //   if (findIndex >= 0) {
+            //     item.hidden = false
+            //   }
+            // }
           });
         });
 
-        const responseData = response.data;
-        for (let i in responseData.tpls) {
-          const findItem = this.cacheFormData.find(
-            (item) => item.tplId == responseData.tpls[i].id
-          );
-          if (findItem) {
-            responseData.tpls[i].form_data = JSON.parse(
-              JSON.stringify(findItem.formData)
-            );
-          } else {
-            responseData.tpls[i].form_data = "";
-          }
-        }
-
         this.processStructureValue = response.data;
         this.currentNode = this.processStructureValue.nodes[0];
 
@@ -385,6 +355,7 @@ export default {
           });
         }
 
+        // 按钮设置
         const psv = response.data.edges || [];
         const btn_group = [];
         psv.forEach((item) => {
@@ -403,17 +374,37 @@ export default {
         });
         this.btn_group = btn_group;
         if (!this.socialId && this.deptList.length <= 0) {
-          // this.$dialog.alert({
-          //   message: "您当前暂未设置所属部门,请联系管理员",
-          //   confirmButtonColor: "#01C1B5"
-          // })
           this.$alert("您当前暂未设置所属部门,请联系管理员", "提示", {
             confirmButtonText: "确定",
-            callback: (action) => {},
+            callback: (action) => { },
           });
         }
       });
     },
+    // // 添加关联表单方法
+    // relationFormChange(value) {
+    //   // false 为显示,true 为隐藏
+    //   let temp = value || [];
+    //   let tempData = JSON.parse(JSON.stringify(this.templateData));
+    //   tempData.forEach((item) => {
+    //     if (this.formStatus) {
+    //       //   判断表单是否在关联列表里,如果在则隐藏
+    //       if (this.formRelationList.includes(item.model)) {
+    //         item.hidden = true;
+    //         this.fileCheckList[item.model] =
+    //           item.type == "subform" ? true : false;
+    //       }
+    //       //   判断是否是文本类型,一直默认显示
+    //       if (item.type == "text") {
+    //         item.hidden = false;
+    //       }
+    //     } else {
+    //       item.hidden = false;
+    //     }
+    //   });
+    //   this.templateData = tempData;
+    //   this.$forceUpdate();
+    // },
     getSelectValueObject(tpls, type = "value", tplValues = []) {
       const tempData = tpls || [];
       let selectList = [];

+ 181 - 181
vue.config.js

@@ -1,181 +1,181 @@
-"use strict";
-const path = require("path");
-const defaultSettings = require("./src/settings.js");
-
-function resolve(dir) {
-  return path.join(__dirname, dir);
-}
-
-const name = defaultSettings.title || "ferry"; // page title
-
-// If your port is set to 80,
-// use administrator privileges to execute the command line.
-// For example, Mac: sudo npm run
-// You can change the port by the following method:
-// port = 9527 npm run dev OR npm run dev --port = 9527
-const port = process.env.port || process.env.npm_config_port || 9527; // dev port
-
-const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
-// const target = "https://manonline.dayaedu.com";
-const target = "https://mantest.dayaedu.com";
-// All configuration item explanations can be find in https://cli.vuejs.org/config/
-module.exports = {
-  /**
-   * You will need to set publicPath if you plan to deploy your site under a sub path,
-   * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
-   * then publicPath should be set to "/bar/".
-   * In most cases please use '/' !!!
-   * Detail: https://cli.vuejs.org/config/#publicpath
-   */
-  publicPath: "/",
-  outputDir: "web",
-  assetsDir: "static/web",
-  lintOnSave: false, // process.env.NODE_ENV === 'development',
-  productionSourceMap: false,
-  devServer: {
-    port: port,
-    open: true,
-    overlay: {
-      warnings: false,
-      errors: true,
-    },
-    proxy: {
-      // change xxx-api/login => mock/login
-      // detail: https://cli.vuejs.org/config/#devserver-proxy
-      // http://47.99.212.176:8000
-      // http://192.168.3.28:8000
-      // http://192.168.3.134
-      // http://47.114.176.40:8000
-      // let target = 'http://dev.dayaedu.com'
-      // 'http://dev.dayaedu.com'
-      "/api-auth": {
-        target: target,
-        // target : target,
-        // changeOrigin: true,
-        pathRewrite: {
-          "^api-auth": "",
-        },
-      },
-      "/api-task": {
-        target: target,
-        changeOrigin: true,
-        pathRewrite: {
-          "^api-task": "",
-        },
-      },
-      "/api-oa": {
-        target: target,
-        changeOrigin: true,
-        pathRewrite: {
-          "^api-task": "",
-        },
-      },
-      "/api-web": {
-        target: target,
-        changeOrigin: true,
-        pathRewrite: {
-          "^api-web": "",
-        },
-      },
-      "/api-cms": {
-        target: target,
-        changeOrigin: true,
-        pathRewrite: {
-          "^api-cms": "",
-        },
-      },
-      "/api-teacher": {
-        target: target,
-        changeOrigin: true,
-        pathRewrite: {
-          "^api-teacher": "",
-        },
-      },
-      "/jiari": {
-        target: "http://tool.bitefu.net",
-        changeOrigin: true,
-      },
-    },
-  },
-  configureWebpack: {
-    plugins: [new MonacoWebpackPlugin()],
-    name: name,
-    resolve: {
-      alias: {
-        "@": resolve("src"),
-      },
-    },
-  },
-  chainWebpack(config) {
-    config.plugins.delete("preload"); // TODO: need test
-    config.plugins.delete("prefetch"); // TODO: need test
-
-    // set svg-sprite-loader
-    config.module.rule("svg").exclude.add(resolve("src/icons")).end();
-    config.module
-      .rule("icons")
-      .test(/\.svg$/)
-      .include.add(resolve("src/icons"))
-      .end()
-      .use("svg-sprite-loader")
-      .loader("svg-sprite-loader")
-      .options({
-        symbolId: "icon-[name]",
-      })
-      .end();
-
-    // set preserveWhitespace
-    config.module
-      .rule("vue")
-      .use("vue-loader")
-      .loader("vue-loader")
-      .tap((options) => {
-        options.compilerOptions.preserveWhitespace = true;
-        return options;
-      })
-      .end();
-
-    config
-      // https://webpack.js.org/configuration/devtool/#development
-      .when(process.env.NODE_ENV === "development", (config) =>
-        config.devtool("cheap-source-map")
-      );
-
-    config.when(process.env.NODE_ENV !== "development", (config) => {
-      config
-        .plugin("ScriptExtHtmlWebpackPlugin")
-        .after("html")
-        .use("script-ext-html-webpack-plugin", [
-          {
-            // `runtime` must same as runtimeChunk name. default is `runtime`
-            inline: /runtime\..*\.js$/,
-          },
-        ])
-        .end();
-      config.optimization.splitChunks({
-        chunks: "all",
-        cacheGroups: {
-          libs: {
-            name: "chunk-libs",
-            test: /[\\/]node_modules[\\/]/,
-            priority: 10,
-            chunks: "initial", // only package third parties that are initially dependent
-          },
-          elementUI: {
-            name: "chunk-elementUI", // split elementUI into a single package
-            priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
-            test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
-          },
-          commons: {
-            name: "chunk-commons",
-            test: resolve("src/components"), // can customize your rules
-            minChunks: 3, //  minimum common number
-            priority: 5,
-            reuseExistingChunk: true,
-          },
-        },
-      });
-      config.optimization.runtimeChunk("single");
-    });
-  },
-};
+"use strict";
+const path = require("path");
+const defaultSettings = require("./src/settings.js");
+
+function resolve(dir) {
+  return path.join(__dirname, dir);
+}
+
+const name = defaultSettings.title || "OA系统"; // page title
+
+// If your port is set to 80,
+// use administrator privileges to execute the command line.
+// For example, Mac: sudo npm run
+// You can change the port by the following method:
+// port = 9527 npm run dev OR npm run dev --port = 9527
+const port = process.env.port || process.env.npm_config_port || 9527; // dev port
+
+const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
+// const target = "https://manonline.dayaedu.com";
+const target = "https://mantest.dayaedu.com";
+// All configuration item explanations can be find in https://cli.vuejs.org/config/
+module.exports = {
+  /**
+   * You will need to set publicPath if you plan to deploy your site under a sub path,
+   * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
+   * then publicPath should be set to "/bar/".
+   * In most cases please use '/' !!!
+   * Detail: https://cli.vuejs.org/config/#publicpath
+   */
+  publicPath: "/",
+  outputDir: "web",
+  assetsDir: "static/web",
+  lintOnSave: false, // process.env.NODE_ENV === 'development',
+  productionSourceMap: false,
+  devServer: {
+    port: port,
+    open: true,
+    overlay: {
+      warnings: false,
+      errors: true,
+    },
+    proxy: {
+      // change xxx-api/login => mock/login
+      // detail: https://cli.vuejs.org/config/#devserver-proxy
+      // http://47.99.212.176:8000
+      // http://192.168.3.28:8000
+      // http://192.168.3.134
+      // http://47.114.176.40:8000
+      // let target = 'http://dev.dayaedu.com'
+      // 'http://dev.dayaedu.com'
+      "/api-auth": {
+        target: target,
+        // target : target,
+        // changeOrigin: true,
+        pathRewrite: {
+          "^api-auth": "",
+        },
+      },
+      "/api-task": {
+        target: target,
+        changeOrigin: true,
+        pathRewrite: {
+          "^api-task": "",
+        },
+      },
+      "/api-oa": {
+        target: target,
+        changeOrigin: true,
+        pathRewrite: {
+          "^api-task": "",
+        },
+      },
+      "/api-web": {
+        target: target,
+        changeOrigin: true,
+        pathRewrite: {
+          "^api-web": "",
+        },
+      },
+      "/api-cms": {
+        target: target,
+        changeOrigin: true,
+        pathRewrite: {
+          "^api-cms": "",
+        },
+      },
+      "/api-teacher": {
+        target: target,
+        changeOrigin: true,
+        pathRewrite: {
+          "^api-teacher": "",
+        },
+      },
+      "/jiari": {
+        target: "http://tool.bitefu.net",
+        changeOrigin: true,
+      },
+    },
+  },
+  configureWebpack: {
+    plugins: [new MonacoWebpackPlugin()],
+    name: name,
+    resolve: {
+      alias: {
+        "@": resolve("src"),
+      },
+    },
+  },
+  chainWebpack(config) {
+    config.plugins.delete("preload"); // TODO: need test
+    config.plugins.delete("prefetch"); // TODO: need test
+
+    // set svg-sprite-loader
+    config.module.rule("svg").exclude.add(resolve("src/icons")).end();
+    config.module
+      .rule("icons")
+      .test(/\.svg$/)
+      .include.add(resolve("src/icons"))
+      .end()
+      .use("svg-sprite-loader")
+      .loader("svg-sprite-loader")
+      .options({
+        symbolId: "icon-[name]",
+      })
+      .end();
+
+    // set preserveWhitespace
+    config.module
+      .rule("vue")
+      .use("vue-loader")
+      .loader("vue-loader")
+      .tap((options) => {
+        options.compilerOptions.preserveWhitespace = true;
+        return options;
+      })
+      .end();
+
+    config
+      // https://webpack.js.org/configuration/devtool/#development
+      .when(process.env.NODE_ENV === "development", (config) =>
+        config.devtool("cheap-source-map")
+      );
+
+    config.when(process.env.NODE_ENV !== "development", (config) => {
+      config
+        .plugin("ScriptExtHtmlWebpackPlugin")
+        .after("html")
+        .use("script-ext-html-webpack-plugin", [
+          {
+            // `runtime` must same as runtimeChunk name. default is `runtime`
+            inline: /runtime\..*\.js$/,
+          },
+        ])
+        .end();
+      config.optimization.splitChunks({
+        chunks: "all",
+        cacheGroups: {
+          libs: {
+            name: "chunk-libs",
+            test: /[\\/]node_modules[\\/]/,
+            priority: 10,
+            chunks: "initial", // only package third parties that are initially dependent
+          },
+          elementUI: {
+            name: "chunk-elementUI", // split elementUI into a single package
+            priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
+            test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
+          },
+          commons: {
+            name: "chunk-commons",
+            test: resolve("src/components"), // can customize your rules
+            minChunks: 3, //  minimum common number
+            priority: 5,
+            reuseExistingChunk: true,
+          },
+        },
+      });
+      config.optimization.runtimeChunk("single");
+    });
+  },
+};