refactor: nladmin-lms init
This commit is contained in:
372
nladmin-ui/src/views/wms/basedata/master/vehicle/index.vue
Normal file
372
nladmin-ui/src/views/wms/basedata/master/vehicle/index.vue
Normal file
@@ -0,0 +1,372 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-suffix=":"
|
||||
>
|
||||
<el-form-item :label="$t('VehicleInfo.table.storagevehicle_type_name')">
|
||||
<treeselect
|
||||
v-model="query.storagevehicle_type"
|
||||
:load-options="loadChildNodes"
|
||||
:options="classes1"
|
||||
style="width: 220px"
|
||||
:placeholder="$t('common.Please_select')"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('VehicleInfo.placeholder.vehicle_no')">
|
||||
<el-input
|
||||
v-model="query.storagevehicle_code_begin"
|
||||
clearable
|
||||
size="mini"
|
||||
:placeholder="$t('VehicleInfo.placeholder.start_vehicle')"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
-
|
||||
<el-input
|
||||
v-model="query.storagevehicle_code_end"
|
||||
clearable
|
||||
size="mini"
|
||||
:placeholder="$t('VehicleInfo.placeholder.end_vehicle')"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<rrOperation />
|
||||
</el-form>
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission">
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="success"
|
||||
icon="el-icon-printer"
|
||||
size="mini"
|
||||
@click="print"
|
||||
>
|
||||
{{ $t('VehicleInfo.button.print') }}
|
||||
</el-button>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog
|
||||
:before-close="crud.cancelCU"
|
||||
:close-on-click-modal="false"
|
||||
:title="crud.status.title"
|
||||
:visible.sync="crud.status.cu > 0"
|
||||
width="450px"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" size="mini" label-position="right" label-width="auto">
|
||||
<el-form-item
|
||||
:label="$t('VehicleInfo.table.storagevehicle_type_name')"
|
||||
prop="storagevehicle_type"
|
||||
>
|
||||
<treeselect
|
||||
v-model="form.storagevehicle_type"
|
||||
:load-options="loadChildNodes"
|
||||
:options="classes1"
|
||||
style="width: 80%"
|
||||
:placeholder="$t('common.Please_select')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<br>
|
||||
<el-form-item :label="$t('VehicleInfo.dialog.num')" prop="num">
|
||||
<el-input-number v-model="form.num" :precision="0" style="width: 80%" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('VehicleInfo.table.is_used')">
|
||||
<el-radio v-model="form.is_used" label="0">{{ $t('common.No') }}</el-radio>
|
||||
<el-radio v-model="form.is_used" label="1">{{ $t('common.Yes') }}</el-radio>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="info" @click="crud.cancelCU">{{ $t('common.Cancel') }}</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">{{ $t('VehicleInfo.dialog.build') }}</el-button>
|
||||
<el-button type="primary" @click="addAndprint">{{ $t('VehicleInfo.dialog.build_print') }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
size="mini"
|
||||
style="width: 100%;"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column
|
||||
prop="storagevehicle_type_name"
|
||||
:label="$t('VehicleInfo.table.storagevehicle_type_name')"
|
||||
:min-width="flexWidth('storagevehicle_code', crud.data, $t('VehicleInfo.table.storagevehicle_type_name'))"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="storagevehicle_code"
|
||||
:label="$t('VehicleInfo.table.storagevehicle_code')"
|
||||
:min-width="flexWidth('storagevehicle_code', crud.data, $t('VehicleInfo.table.storagevehicle_code'))"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="storagevehicle_name"
|
||||
:label="$t('VehicleInfo.table.storagevehicle_name')"
|
||||
:min-width="flexWidth('storagevehicle_name', crud.data, $t('VehicleInfo.table.storagevehicle_name'))"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="create_name"
|
||||
:label="$t('VehicleInfo.table.create_user')"
|
||||
:min-width="flexWidth('create_name', crud.data, $t('VehicleInfo.table.create_user'))"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="create_time"
|
||||
:label="$t('VehicleInfo.table.create_time')"
|
||||
:min-width="flexWidth('create_time', crud.data, $t('VehicleInfo.table.create_time'))"
|
||||
/>
|
||||
<el-table-column :label="$t('VehicleInfo.table.is_used')" align="center" prop="is_used">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
:value="format_is_used(scope.row.is_used)"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
@change="changeEnabled(scope.row, scope.row.is_used)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-permission="[]" :label="$t('common.Operate')" width="120px" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
:is-visiable-edit="false"
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudClassstandard from '@/views/wms/basedata/master/classification/mdBaseClassstandard'
|
||||
import crudStoragevehicleinfo from './storagevehicleinfo'
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import { getLodop } from '@/assets/js/lodop/LodopFuncs'
|
||||
import i18n from '@/i18n'
|
||||
|
||||
const defaultForm = {
|
||||
storagevehicle_id: null,
|
||||
storagevehicle_code: null,
|
||||
storagevehicle_name: null,
|
||||
one_code: null,
|
||||
two_code: null,
|
||||
rfid_code: null,
|
||||
create_id: null,
|
||||
create_name: null,
|
||||
create_time: null,
|
||||
update_optid: null,
|
||||
update_optname: null,
|
||||
update_time: null,
|
||||
is_delete: null,
|
||||
is_used: '1',
|
||||
storagevehicle_type: null,
|
||||
vehicle_width: null,
|
||||
vehicle_long: null,
|
||||
vehicle_height: null,
|
||||
overstruct_type: null,
|
||||
occupystruct_qty: null,
|
||||
ext_id: null,
|
||||
num: '1'
|
||||
}
|
||||
export default {
|
||||
name: 'Storagevehicleinfo',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation, Treeselect },
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
cruds() {
|
||||
return CRUD({
|
||||
title: i18n.t('VehicleInfo.title'),
|
||||
url: 'api/storagevehicleinfo',
|
||||
idField: 'storagevehicle_id',
|
||||
sort: 'storagevehicle_id,desc',
|
||||
crudMethod: { ...crudStoragevehicleinfo },
|
||||
optShow: {
|
||||
add: true,
|
||||
edit: false,
|
||||
del: false,
|
||||
download: false,
|
||||
reset: true
|
||||
}
|
||||
})
|
||||
},
|
||||
data() {
|
||||
var numberOne = (rule, value, callback) => {
|
||||
const numReg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/
|
||||
const numRe = new RegExp(numReg)
|
||||
if (!numRe.test(value)) {
|
||||
callback(new Error(i18n.t('VehicleInfo.msg.only_num')))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
permission: {},
|
||||
rules: {
|
||||
create_id: [
|
||||
{ required: true, message: i18n.t('VehicleInfo.rules.NotNull'), trigger: 'blur' }
|
||||
],
|
||||
create_name: [
|
||||
{ required: true, message: i18n.t('VehicleInfo.rules.NotNull'), trigger: 'blur' }
|
||||
],
|
||||
create_time: [
|
||||
{ required: true, message: i18n.t('VehicleInfo.rules.NotNull'), trigger: 'blur' }
|
||||
],
|
||||
is_delete: [
|
||||
{ required: true, message: i18n.t('VehicleInfo.rules.NotNull'), trigger: 'blur' }
|
||||
],
|
||||
is_used: [
|
||||
{ required: true, message: i18n.t('VehicleInfo.rules.NotNull'), trigger: 'blur' }
|
||||
],
|
||||
storagevehicle_type: [
|
||||
{ required: true, message: i18n.t('VehicleInfo.rules.NotNull'), trigger: 'blur' }
|
||||
],
|
||||
overstruct_type: [
|
||||
{ required: true, message: i18n.t('VehicleInfo.rules.NotNull'), trigger: 'blur' }
|
||||
],
|
||||
num: [
|
||||
{ required: true, message: i18n.t('VehicleInfo.rules.NotNull'), trigger: 'blur' },
|
||||
{ validator: numberOne }
|
||||
]
|
||||
},
|
||||
classes1: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.initClass1()
|
||||
},
|
||||
methods: {
|
||||
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
},
|
||||
initClass1() {
|
||||
const param = {
|
||||
parent_class_code: 'vehicle_type'
|
||||
}
|
||||
crudClassstandard.getClassType(param).then(res => {
|
||||
debugger
|
||||
const data = res
|
||||
this.buildTree(data)
|
||||
this.classes1 = data
|
||||
})
|
||||
},
|
||||
buildTree(classes) {
|
||||
classes.forEach(data => {
|
||||
if (data.children) {
|
||||
this.buildTree(data.children)
|
||||
}
|
||||
if (data.hasChildren && !data.children) {
|
||||
data.children = null // 重点代码
|
||||
}
|
||||
})
|
||||
},
|
||||
// 获取子节点数据
|
||||
loadChildNodes({ action, parentNode, callback }) {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
crudClassstandard.getClass({ pid: parentNode.id }).then(res => {
|
||||
parentNode.children = res.map(function(obj) {
|
||||
if (obj.hasChildren) {
|
||||
obj.children = null
|
||||
}
|
||||
return obj
|
||||
})
|
||||
setTimeout(() => {
|
||||
callback()
|
||||
}, 100)
|
||||
})
|
||||
}
|
||||
},
|
||||
format_is_used(is_used) {
|
||||
return is_used === '1'
|
||||
},
|
||||
changeEnabled(data, val) {
|
||||
console.log(data)
|
||||
const msg = val !== '1' ? i18n.t('VehicleInfo.msg.tip1') : i18n.t('VehicleInfo.msg.tip2')
|
||||
this.$confirm(msg, i18n.t('common.Tips'), {
|
||||
confirmButtonText: i18n.t('common.Confirm'),
|
||||
cancelButtonText: i18n.t('common.Cancel'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
crudStoragevehicleinfo.changeActive(data).then(res => {
|
||||
this.crud.toQuery()
|
||||
this.crud.notify(i18n.t('common.Operation_success'), CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
}).catch(() => {
|
||||
data.is_used = !data.is_used
|
||||
})
|
||||
})
|
||||
},
|
||||
print() {
|
||||
const _selectData = this.$refs.table.selection
|
||||
if (!_selectData || _selectData.length < 1) {
|
||||
this.crud.notify(i18n.t('VehicleInfo.msg.tip3'), CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return
|
||||
}
|
||||
for (let i = 0; i < _selectData.length; i++) {
|
||||
const code = _selectData[i].storagevehicle_code
|
||||
const LODOP = getLodop()
|
||||
LODOP.SET_SHOW_MODE('HIDE_DISBUTTIN_SETUP', 1)// 隐藏那些无效按钮
|
||||
// 打印纸张大小设置https://www.it610.com/article/2094844.html
|
||||
LODOP.SET_PRINT_PAGESIZE(1, '50mm', '30mm', '')
|
||||
// LODOP.ADD_PRINT_RECT('0mm', '0mm', '48mm', '28mm', 0, 1)
|
||||
LODOP.ADD_PRINT_BARCODE('4.3mm', '8.2mm', '40mm', '20mm', '128Auto', code)
|
||||
// LODOP.PREVIEW()// 预览
|
||||
LODOP.PRINT()// 打印
|
||||
this.crud.notify(i18n.t('VehicleInfo.msg.tip4'), CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.crud.toQuery()
|
||||
}
|
||||
},
|
||||
addAndprint() {
|
||||
const data = this.form
|
||||
if (!this.form.storagevehicle_type) {
|
||||
this.crud.notify(i18n.t('VehicleInfo.msg.tip5'), CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return false
|
||||
}
|
||||
if (!this.form.num) {
|
||||
this.crud.notify(i18n.t('VehicleInfo.msg.tip6'), CRUD.NOTIFICATION_TYPE.INFO)
|
||||
return false
|
||||
}
|
||||
crudStoragevehicleinfo.add(data).then(res => {
|
||||
res.forEach((item) => {
|
||||
const LODOP = getLodop()
|
||||
LODOP.SET_SHOW_MODE('HIDE_DISBUTTIN_SETUP', 1)// 隐藏那些无效按钮
|
||||
// 打印纸张大小设置https://www.it610.com/article/2094844.html
|
||||
LODOP.SET_PRINT_PAGESIZE(1, '50mm', '30mm', '1')
|
||||
// LODOP.ADD_PRINT_RECT('0mm', '0mm', '50mm', '30mm', 0, 1)
|
||||
LODOP.ADD_PRINT_BARCODE('4.3mm', '6.2mm', '40mm', '20mm', '128Auto', item)
|
||||
// LODOP.PREVIEW()// 预览
|
||||
LODOP.PRINT()// 打印
|
||||
})
|
||||
this.crud.status.add = CRUD.STATUS.NORMAL
|
||||
this.crud.toQuery()
|
||||
this.crud.notify(i18n.t('VehicleInfo.msg.tip4'), CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user