@{
|
ViewBag.Title = "Index";
|
Layout = "~/Views/Shared/_LayoutVue.cshtml";
|
}
|
@section head{
|
<style>
|
.el-input {
|
font-size: 14px;
|
display: inline-block;
|
width: 120px;
|
}
|
</style>
|
}
|
<el-container id="idMain">
|
<el-form label-width="100px" class="demo-ruleForm" v-bind:inline="true">
|
<el-form-item label="仓库名:">
|
<hh-select-url v-model="stockCode"
|
url="/Basic/Common/StockList"
|
valuefield="CN_S_STOCK_CODE"
|
textfield="CN_S_STOCK_NAME"
|
datafield="Data">
|
</hh-select-url>
|
</el-form-item>
|
</el-form>
|
<el-tabs type="card" v-on:click="handleClick">
|
<el-tab-pane v-for="group in groups" v-bind:label="group.CN_S_GROUP">
|
<el-form label-width="150px" class="demo-ruleForm" v-bind:inline="true">
|
<el-form-item v-for="item in groupItems[group.CN_S_GROUP]" v-bind:label="item.CN_S_NAME">
|
<el-input v-if="item.CN_S_VALUE_TYPE==='数值'" required size="mini" v-model="item.CN_S_VALUE"></el-input>
|
<el-checkbox v-if="item.CN_S_VALUE_TYPE==='bool'" v-model="item.CN_S_VALUE"></el-checkbox>
|
<hh-select-url v-if="item.CN_S_VALUE_TYPE==='字典'"
|
v-model="item.CN_S_VALUE"
|
v-bind:url="'/Basic/Common/GetDictionary?dictName='+item.CN_S_DIC_NAME"
|
valuefield="NAME"
|
textfield="NAME">
|
</hh-select-url>
|
</el-form-item>
|
</el-form>
|
</el-tab-pane>
|
</el-tabs>
|
<el-footer>
|
<el-row style="padding:10px;text-align:center" >
|
<el-button size="mini" type="primary" v-on:click="save" v-show="!readOnly">保 存</el-button>
|
</el-row>
|
</el-footer>
|
</el-container>
|
|
@section scripts{
|
<script src="~/Content/js/linq.js_ver2.2.0.2/linq.js"></script>
|
<script>
|
new Vue({
|
el: '#idMain',
|
data: {
|
stockCode:"",
|
groups: [], //策略分组
|
groupItems: {},//分组内的设置项
|
oldValues: [],//旧的设置选项
|
items: [],//总的设置选项
|
values: [],
|
changedItemSum:0,//更新值的项目数量
|
},
|
mounted: function () {
|
var $this = this;
|
this.loadData();
|
},
|
watch: {
|
stockCode: function ()
|
{
|
this.loadValue();
|
}
|
},
|
methods: {
|
loadData: function () {
|
var $this = this;
|
ajaxManage({
|
url: "@Url.Action("GetSetOption")",
|
success: function (result) {
|
result.Data.forEach(function (value, index, array) {
|
if (value.CN_S_VALUE_TYPE == 'bool')
|
value.CN_S_VALUE = value.CN_S_VALUE == 'Y' ? true : false;
|
});
|
$this.items = result.Data;
|
$this.groups = Enumerable.From(result.Data).GroupBy("$.CN_S_GROUP", null,
|
function (key, g) {
|
var result2 = {
|
CN_S_GROUP: key
|
}
|
return result2;
|
}).ToArray();
|
|
$this.groups.forEach(function (value, index, array) {
|
$this.groupItems[value.CN_S_GROUP] = Enumerable.From($this.items).Where("x=>x.CN_S_GROUP=='" + value.CN_S_GROUP + "'").ToArray();
|
});
|
}
|
});
|
},
|
loadValue: function () {
|
var $this = this;
|
ajaxManage({
|
url: "@Url.Action("GetOptionValue")?stockCode=" + $this.stockCode,
|
success: function (result)
|
{
|
if (result.Success) {
|
//获取仓库下的设置值
|
$this.items.forEach(function (value, index, array) {
|
if (value.CN_S_VALUE_TYPE == 'bool') {
|
$this.CN_S_VALUE = false;
|
}
|
else {
|
$this.CN_S_VALUE = '';
|
}
|
});
|
|
result.Data.forEach(function (value, index, array) {
|
var obj = Enumerable.From($this.items).Where("x=>x.CN_S_CODE=='" + value.CN_S_CODE + "'").ToArray()[0];
|
if (obj.CN_S_VALUE_TYPE == 'bool') {
|
obj.CN_S_VALUE = value.CN_S_VALUE == 'Y' ? true : false;
|
}
|
else {
|
obj.CN_S_VALUE = value.CN_S_VALUE;
|
}
|
});
|
|
$this.oldValues = JSON.parse(JSON.stringify($this.items));
|
}
|
else {
|
alert(result.Msg);
|
}
|
}
|
});
|
},
|
handleClick:function(tab, event)
|
{
|
console.log(tab, event);
|
},
|
save: function () {
|
var $this = this;
|
|
if ($this.stockCode == "")
|
{
|
wms.error("请选择仓库!");
|
return false;
|
}
|
|
var newItems = [];
|
|
$this.items.forEach(function (value, index, array) {
|
var oldValue = $this.oldValues[value.CN_S_CODE];
|
|
var newItemObj = Enumerable.From($this.items).Where("x=>x.CN_S_CODE=='" + value.CN_S_CODE + "'").ToArray()[0];
|
|
if (newItemObj.CN_S_VALUE != oldValue) {
|
if (newItemObj.CN_S_VALUE_TYPE == "bool") {
|
if (newItemObj.CN_S_VALUE)
|
newItems.push({ CN_S_CODE: newItemObj.CN_S_CODE, CN_S_VALUE: "Y" });
|
else
|
newItems.push({ CN_S_CODE: newItemObj.CN_S_CODE, CN_S_VALUE: "N" });
|
}
|
else
|
newItems.push({ CN_S_CODE: newItemObj.CN_S_CODE, CN_S_VALUE: newItemObj.CN_S_VALUE });
|
}
|
});
|
|
ajaxManage({
|
url: "@Url.Action("Save")?stockCode=" + $this.stockCode + "&ChangedItems=" + JSON.stringify(newItems),
|
success: function (result) {
|
if (result.Success)
|
{
|
wms.success("保存成功!");
|
}
|
else
|
wms.error(result.Msg);
|
}
|
});
|
}
|
}
|
});
|
</script>
|
}
|