Browse Source

Merge branch 'gva_gormv2_dev' of https://github.com/flipped-aurora/gin-vue-admin into gva_gormv2_dev

main
SliverHorn 4 years ago
parent
commit
f74ba3d5bf
  1. 11
      server/utils/cmd_Task.go
  2. 7
      web/src/components/upload/image.vue
  3. 8
      web/src/utils/stringFun.js
  4. 10
      web/src/view/systemTools/autoCode/component/fieldDialog.vue

11
server/utils/cmd_Task.go

@ -73,17 +73,12 @@ func newT(f func(chan struct{}) error) *T {
//@description: 添加任务
func (t *T) AddTask() {
if len(t.ch) == 1 {
return
}
t.Lock()
defer t.Unlock()
if len(t.ch) == 1 {
select {
case t.ch <- struct{}{}:
default:
// 代表已经有任务了
// 直接丢弃这次任务
return
}
t.ch <- struct{}{}
}
//@author: [songzhibin97](https://github.com/songzhibin97)

7
web/src/components/upload/image.vue

@ -13,18 +13,20 @@
<el-upload
class="image-uploader"
:action="`${path}/fileUploadAndDownload/upload`"
:headers="{ 'x-token': token }"
:show-file-list="false"
:on-success="handleImageSuccess"
:before-upload="beforeImageUpload"
:multiple="false"
>
<img v-if="imageUrl" :src="imageUrl" class="image" />
<img v-if="imageUrl" :src="path + imageUrl" class="image" />
<i v-else class="el-icon-plus image-uploader-icon"></i>
</el-upload>
</div>
</template>
<script>
const path = process.env.VUE_APP_BASE_API;
import { mapGetters } from "vuex";
import ImageCompress from "@/utils/image.js";
export default {
name: "upload-image",
@ -51,6 +53,9 @@ export default {
path: path,
};
},
computed: {
...mapGetters("user", ["userInfo", "token"]),
},
methods: {
beforeImageUpload(file) {
let isRightSize = file.size / 1024 < this.fileSize;

8
web/src/utils/stringFun.js

@ -7,6 +7,14 @@ export const toUpperCase = (str) => {
}
}
export const toLowerCase = (str) => {
if (str[0]) {
return str.replace(str[0], str[0].toLowerCase())
} else {
return ""
}
}
// 驼峰转换下划线
export const toSQLLine = (str) => {
if (str == "ID") return "ID"

10
web/src/view/systemTools/autoCode/component/fieldDialog.vue

@ -12,6 +12,9 @@
<el-col :span="6">
<el-input v-model="dialogMiddle.fieldName" autocomplete="off"></el-input>
</el-col>
<el-col :offset="1" :span="2">
<el-button @click="autoFill">自动填充</el-button>
</el-col>
</el-form-item>
<el-form-item label="Field中文名" prop="fieldDesc">
<el-col :span="6">
@ -103,6 +106,7 @@
</template>
<script>
import { getDict } from "@/utils/dictionary";
import { toSQLLine , toLowerCase } from "@/utils/stringFun.js";
import { getSysDictionaryList } from "@/api/sysDictionary";
export default {
name: "FieldDialog",
@ -183,6 +187,10 @@ export default {
};
},
methods: {
autoFill(){
this.dialogMiddle.fieldJson = toLowerCase(this.dialogMiddle.fieldName)
this.dialogMiddle.columnName = toSQLLine(this.dialogMiddle.fieldJson)
},
async getDbfdOptions() {
this.dialogMiddle.dataType = ""
this.dialogMiddle.dataTypeLong = ""
@ -201,7 +209,7 @@ export default {
});
this.dictOptions = dictRes.data.list
}
},
};
</script>
<style lang="scss">

Loading…
Cancel
Save