前端字段如何动态改变(数据库字典项及Vue相关用法)

本文探讨了如何在前端利用Vue的v-for和v-if指令结合后端MySQL或Redis数据字典,动态改变前端字段的显示。通过OrderHandler和OrderGoodsHandler的示例代码,解释了在orderList.html与orderDetail.html中实现这一功能的方法。
摘要由CSDN通过智能技术生成

本文介绍了一些关于Vue中的v-for和v-if的用法,结合数据字典在前段动态显示标签值:

一、前端代码:

(二)orderList.html:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.11/vue.min.js"></script>
		<script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.13.2/index.js"></script>
		<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0/axios.min.js"></script>
		<script src="https://cdn.bootcdn.net/ajax/libs/qs/6.9.4/qs.min.js"></script>
		<script src="https://cdn.bootcdn.net/ajax/libs/vue-router/3.4.3/vue-router.js"></script>
		<link href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.13.2/theme-chalk/index.css" rel="stylesheet">
		<link rel="shortcut icon" href="#" />
		<script src="../js/base.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			.el-input__inner {
    
				height: 30px;
			}
		</style>
	</head>
	<body>
		<div id="app" style="padding-top: 2%;">

			<!-- 面包屑 -->
			<el-breadcrumb separator-class="el-icon-arrow-right" style="padding-bottom: 30px	;">
				<el-breadcrumb-item><a href="welcome.html">首页</a></el-breadcrumb-item>
				<el-breadcrumb-item><a href="">销售管理</a></el-breadcrumb-item>
				<el-breadcrumb-item><a href="">销售订单管理</a></el-breadcrumb-item>
				<el-breadcrumb-item>销售订单查询</el-breadcrumb-item>
			</el-breadcrumb>
			<!-- <hr style="width: 20%;margin-left: 0px;"> -->

			<!-- 查询 -->
			<el-form :inline="true" :model="selectForm" class="demo-form-inline">
				<el-form-item label="订单编号:">
					<el-input title="模糊查询" v-model="selectForm.ordernumber" placeholder="订单编号" maxlength="10" show-word-limit style="width: 180px"
					 clearable></el-input>
				</el-form-item>
				<el-form-item label="订单日期:">
					<el-input title="模糊查询" v-model="selectForm.orderdate" placeholder="订单日期" maxlength="12" show-word-limit style="width: 180px"
					 clearable></el-input>
				</el-form-item>
				<el-form-item label="订单类型:">
					<el-select v-model="selectForm.ordertype" placeholder="全部" style="width: 180px" clearable>
						<el-option v-for="item in orderTypeOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="订单动作:">
					<el-select v-model="selectForm.orderaction" placeholder="全部" style="width: 180px" clearable>
						<el-option v-for="item in orderActionOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="业务类型:">
					<el-select v-model="selectForm.businesstype" placeholder="全部" style="width: 180px" clearable>
						<el-option v-for="item in businessTypeOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="支付方式:">
					<el-select v-model="selectForm.paytype" placeholder="全部" style="width: 180px" clearable>
						<el-option v-for="item in payTypeOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="配送方式:">
					<el-select v-model="selectForm.transporttype" placeholder="全部" style="width: 180px" clearable>
						<el-option v-for="item in transportTypeOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="订单状态:">
					<el-select v-model="selectForm.orderstatus" placeholder="全部" style="width: 180px" clearable>
						<el-option v-for="item in orderStatusOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item style="padding-left: 10%;">
					<el-button type="danger" @click="dialogOfUpload = true" size="medium">上传</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" @click="queryOrder()" size="medium">查询</el-button>
				</el-form-item>
				<el-form-item>
					<el-button type="info" @click="refresh()" size="medium">刷新</el-button>
				</el-form-item>
				<el-form-item>
					<el-button v-if="this.status==1" disabled type="success" @click="check()" size="medium" title="将【待出库】订单下所有商品置为【待出库】状态">校验出库单</el-button>
					<el-button v-else type="success" @click="check()" size="medium" title="将【待出库】订单下所有商品置为【待出库】状态">校验出库单</el-button>
				</el-form-item>
				<el-form-item>
					<el-button v-if="this.status==0" disabled type="warning" @click="generate()" size="medium" title='选择【待出库】订单'>生成出库单</el-button>
					<el-button v-else type="warning" @click="generate()" size="medium" title='选择【待出库】订单'>生成出库单</el-button>
				</el-form-item>
			</el-form>

			<span style="padding-left: 2%;font-weight: bold;font-size: 20px;">订单信息表</span>
			<hr>
			<!-- 表格 -->
			<template>
				<el-table @selection-change="handleSelectionChange" :row-style="{
      height:0+'px'}" :cell-style="{
      padding:0+'px'}"
				 :header-cell-style="{
      background:'#F5F7FA',color:'#606266', height:'10px', padding:'0px'}" style="margin-top:10px"
				 highlight-current-row="true" :data="tableData" border style="width: 100%" :default-sort="{prop: 'orderid', order: 'ascending'}">
					<el-table-column align="center" type="selection" width="55"></el-table-column>
					<el-table-column align="center" fixed prop="orderid" label="订单ID" min-width="10%" show-overflow-tooltip="true"
					 sortable>
					</el-table-column>
					<el-table-column align="center" prop="ordernumber" label="订单编号" min-width="10%" sortable>
					</el-table-column>
					<el-table-column align="center" prop="orderdate" label="下单日期" min-width="10%" sortable>
					</el-table-column>
					<el-table-column align="center" prop="ordertype" label="订单类型" min-width="10%" sortable>
						<template slot-scope="scope">
							<span v-for="item in orderTypeOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue" v-if="scope.row.ordertype==item.dvalue">{
  {item.dlabel}}</span>
						</template>
					</el-table-column>
					<el-table-column align="center" prop="orderaction" label="订单动作" min-width="10%" sortable>
						<template slot-scope="scope">
							<span v-for="item in orderActionOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue" v-if="scope.row.orderaction==item.dvalue">{
  {item.dlabel}}</span>
						</template>
					</el-table-column>
					<el-table-column align="center" prop="businesstype" label="业务类型" min-width="10%" sortable>
						<template slot-scope="scope">
							<span v-for="item in businessTypeOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue" v-if="scope.row.businesstype==item.dvalue">{
  {item.dlabel}}</span>
						</template>
					</el-table-column>
					<el-table-column align="center" prop="paytype" label="支付方式" min-width="10%" sortable>
						<template slot-scope="scope">
							<span v-for="item in payTypeOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue" v-if="scope.row.paytype==item.dvalue">{
  {item.dlabel}}</span>
						</template>
					</el-table-column>
					<el-table-column align="center" prop="transporttype" label="配送方式" min-width="10%" sortable>
						<template slot-scope="scope">
							<span v-for="item in transportTypeOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue" v-if="scope.row.transporttype==item.dvalue">{
  {item.dlabel}}</span>
						</template>
					</el-table-column>
					<el-table-column align="center" prop="orderstatus" label="订单状态" min-width="10%" sortable>
						<template slot-scope="scope">
							<template v-for="item in orderStatusOptions" :key="item.dvalue" :label="item.dlabel" :value="item.dvalue" v-if="scope.row.orderstatus==item.dvalue">
								<span v-if="scope.row.orderstatus=='1'" style="color: blue;font-weight: bold;">{
  {item.dlabel}}</span>
								<span v-if="scope.row.orderstatus=='2'" style="color: green;font-weight: bold;">{
  {item.dlabel}}</span>
								<span v-if="scope.row.orderstatus=='3'" style="color: red;font-weight: bold;">{
  {item.dlabel}}</span>
							</template>
						</template
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值