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 / 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.js
Created December 19, 2017 01:54
API service configuration of a vuejs project.
import settings from 'settings'
export const baseUrls = new ProjectSettings(settings, [
'ibasic-api', 'iqc-api'
]).baseUrls
@wisetc
wisetc / example.js
Created December 19, 2017 02:07
Standard front-end data model methods by transforming back-end unified api of my company. 面向表的编程。
import { XTRequest } from './configure'
const IBASIC_API_BASE_URL = 'http://192.168.2.103:5555/ibasic-api'
export const iBaseAPI = new XTRequest(IBASIC_API_BASE_URL, ['custom', 'supplier', 'warehouse']).models
const api = iBaseAPI.custom
@wisetc
wisetc / Detail.vue
Created December 21, 2017 06:28
stupid backend developer to develop hard-to-use api.
<template lang="pug">
tb-wrapper(title='配方工艺明细')
el-table(v-loading='loading', :data='data', border stripe)
el-table-column(label='原料', width='200px', prop='material.materialName' show-overflow-tooltip)
el-table-column(label='称料顺序', width='120px', align='center')
template(slot-scope="scope")
span(v-if="!scope.row.__editable__") {{ scope.row.weightSeq }}
m-input-number(v-else int :max="1000" v-model="scope.row.__form__.weightSeq" style="width:96%;")
el-table-column(label='投料顺序', width='120px', align='center')
template(slot-scope="scope")