Skip to content

Instantly share code, notes, and snippets.

View wisetc's full-sized avatar
😉
missing

Ben wisetc

😉
missing
  • 中国·杭州
View GitHub Profile
@wisetc
wisetc / responsive-slider.js
Created June 19, 2017 08:18
responsive slider based on swiperjs.
import $ from 'jquery';
import Swiper from 'swiper';
import 'swiper/dist/css/swiper.min.css';
$(function () {
var mySwiper = null;
// page load complete
@wisetc
wisetc / InputNumber.vue
Last active November 22, 2020 16:11
Vue component number input to replace el-input-number of element-ui.
<script>
import emitter from 'element-ui/src/mixins/emitter';
export default {
mixins: [emitter],
props: {
value: Number,
max: { type: Number, default: 99999 },
min: { type: Number, default: 0 },
int: { type: Boolean, default: false },
@wisetc
wisetc / axios-configure.js
Last active November 27, 2018 19:57
Configuration of axios instance to make POST requests.
import axios from 'axios'
import { Message } from 'element-ui'
export const baseUrl = 'http://example.com/api';
const transformRequest = (data={}) => {
if (typeof data === 'string') return data;
if (!data.oauth)
data.oauth = localStorage.getItem("token")? localStorage.getItem("token"): (sessionStorage.getItem("token") || "");
@wisetc
wisetc / inline-el-autocomplete.vue
Last active September 29, 2017 03:26
el-autocomplete in el-table inline suggestion.
<template lang="pug">
el-table(:data="data" border)
el-table-column(label="批次")
template(scope="scope")
el-autocomplete(v-model="scope.row.rowTempModel.batch" :maxlength="50" style="width:100%;"
:fetch-suggestions="(queryString, cb) => {\
searchBatchOpt(scope.row, scope.$index).then(batchs => { \
let suggestions = batchs.map(batch => ({value: batch})); \
queryString ? cb(suggestions.filter(suggestion => suggestion.value.indexOf(queryString) > -1)) : cb(suggestions.slice(0,6))\
});\
@wisetc
wisetc / DateGrid.vue
Created October 8, 2017 01:10
某年某月的工作排班信息表
<template lang="pug">
#date-grid
table.date-grid
thead
th 班次\日期
th(v-for="num in colNum" :key="num.$index") {{ num }}
tbody
tr(v-for="(classTime, rowIndex) in classTimeList" :key="rowIndex")
th {{ classTime.name }}
template(v-for="(cell, colIndex) in cells[rowIndex]")
@wisetc
wisetc / RepairStation.vue
Last active October 19, 2017 01:59
vue CRUD component base on element-ui
<template>
<div>
<crud :data="data" :form="form" :rules="rules" :fields="mapItems"
:editing="editing" @open="handleOpen" @close="handleClose"
@create="handleCreate" @update="handleUpdate" @destroy="handleDestroy" @submit="handleSubmit"/>
</div>
</template>
<script>
@wisetc
wisetc / Pagination.vue
Created October 20, 2017 06:41
vue mixins pagination based on element-ui.
<template>
<div>
<el-pagination
v-if="pagination.total > 10"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pagination.current"
:page-sizes="pagination.sizes"
:page-size="pagination.size"
layout="sizes, prev, pager, next"
@wisetc
wisetc / basic.js
Created November 8, 2017 01:02
Forge request api object for standard backend api.
import { api } from './configure'
export const Accessory = api('accessory')
export const Supplier = api('supplier')
export const Device = api('device')
export const Dict = api('dict')
@wisetc
wisetc / vue-number-input
Created November 10, 2017 07:56
Use vuejs watch feature to force the input to input Integer only and not float is allowed.
watch: {
'form.amount'(val, oldVal) {
if (!Number.isInteger(val)) {
this.$nextTick(() => {
this.form.amount = parseInt(val, 10)
})
}
}
}
@wisetc
wisetc / example.vue
Last active May 18, 2020 08:09
vue searcher based on element-ui.
<template>
<div>
<m-searcher :kw="kw" :fields="searchFields" :placeholders="placeholders" @search="loadData">
<el-select v-model="kw.moldsId" clearable size="small" @clear="loadData" class="search-box__input">
<el-option :key="index" v-for="(o, index) in molds"
:label="o.code" :value="o.id"/>
</el-select>
</m-searcher>
</div>
</template>