<!-- 盘点新增/Add -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="../../layui/css/layui.css">
<link rel="stylesheet" href="../../css/diy.css">
<script src="../../js/axios.min.js"></script>
<style>
img {
width: 200px;
}
.layui-upload-list{
overflow: hidden;
}
.layui-upload-list .multiple_block .upload_img_multiple{
height: auto;
width: 100px;
}
.multiple_block{
position: relative;
float: left;
width: 100px;
margin: 0 10px 10px 0;
}
.multiple_block .upload-img-del{
position: absolute;
top: 5px;
right: 5px;
color: #fff;
border-radius: 100%;
background: #0000009c;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
cursor: pointer;
}
</style>
</head>
<body>
<article class="sign_in">
<div class="warp tpl">
<div class="layui-container">
<div class="layui-row">
<form class="layui-form" action="">
<div class="form-input-box from-input-box-i">
<div class="layui-form-item unique" id="warehouse_name_box">
<label class="layui-form-label">仓库名称</label>
<div class="layui-input-block input-i block">
<input type="text" name="title" lay-verify="title" autocomplete="off"
placeholder="请输入仓库名称"
class="layui-input" id="warehouse_name">
</div>
</div>
<div class="layui-form-item unique" id="goods_number_box">
<label class="layui-form-label">货物编号</label>
<div class="layui-input-block input-i block">
<input type="text" name="title" lay-verify="title" autocomplete="off"
placeholder="请输入货物编号"
class="layui-input" id="goods_number">
</div>
</div>
<div class="layui-form-item unique" id="name_of_goods_box">
<label class="layui-form-label">货物名称</label>
<div class="layui-input-block input-i block">
<input type="text" name="title" lay-verify="title" autocomplete="off"
placeholder="请输入货物名称"
class="layui-input" id="name_of_goods">
</div>
</div>
<div class="layui-form-item unique" id="classification_of_goods_box">
<label class="layui-form-label">货物分类</label>
<div class="layui-input-block input-i block">
<input type="text" name="title" lay-verify="title" autocomplete="off"
placeholder="请输入货物分类"
class="layui-input" id="classification_of_goods">
</div>
</div>
<div class="layui-form-item number" id="inventory_of_goods_box">
<label class="layui-form-label">货物库存</label>
<div class="layui-input-block input-i block">
<input type="number" name="num" class="layui-input num" id="inventory_of_goods">
</div>
</div>
<div class="layui-form-item unique" id="storage_location_box">
<label class="layui-form-label">存放位置</label>
<div class="layui-input-block input-i block">
<input type="text" name="title" lay-verify="title" autocomplete="off"
placeholder="请输入存放位置"
class="layui-input" id="storage_location">
</div>
</div>
<div class="layui-form-item uid-box" id="employee_users_box">
<label class="layui-form-label">员工</label>
<div class="layui-input-block select block">
<select name="interest" lay-filter="employee_users"
id="employee_users">
<option value=""></option>
</select>
</div>
</div>
<div class="layui-form-item unique" id="employee_name_box">
<label class="layui-form-label">员工姓名</label>
<div class="layui-input-block input-i block">
<input type="text" name="title" lay-verify="title" autocomplete="off"
placeholder="请输入员工姓名"
class="layui-input" id="employee_name">
</div>
</div>
<div class="layui-form-item unique" id="employee_id_box">
<label class="layui-form-label">员工工号</label>
<div class="layui-input-block input-i block">
<input type="text" name="title" lay-verify="title" autocomplete="off"
placeholder="请输入员工工号"
class="layui-input" id="employee_id">
</div>
</div>
<div class="layui-form-item tiem-box" id="inventory_date_box">
<div class="layui-inline">
<label class="layui-form-label">盘点日期</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" id="inventory_date"
placeholder="">
</div>
</div>
</div>
<div class="layui-form-item number" id="physical_inventory_box">
<label class="layui-form-label">盘点数量</label>
<div class="layui-input-block input-i block">
<input type="number" name="num" class="layui-input num" id="physical_inventory">
</div>
</div>
<div class="layui-form-item layui-form-text" id="inventory_notes_box">
<label class="layui-form-label">盘点备注</label>
<div class="layui-input-block text">
<textarea placeholder="请输入盘点备注" class="layui-textarea"
id="inventory_notes"></textarea>
</div>
</div>
</div>
</form>
<div class="layui-btn-container">
<button type="button" class="layui-btn layui-btn-normal login" id="submit">确认</button>
<button type="button" class="layui-btn layui-btn-normal login" id="cancel">取消</button>
</div>
</div>
</div>
</div>
</article>
</body>
<script src="../../layui/layui.js"></script>
<script src="../../js/base.js"></script>
<script src="../../js/index.js"></script>
<script>
var BaseUrl = baseUrl()
let cancel = document.querySelector("#cancel")
cancel.addEventListener("click",()=>{
colseLayer()
})
let inventory_records_id = location.search.substring(1)
layui.use(['upload', 'element', 'layer', 'laydate', 'layedit'], function () {
var $ = layui.jquery
, upload = layui.upload
, element = layui.element
, layer = layui.layer
, laydate = layui.laydate
, layedit = layui.layedit
, form = layui.form;
let url
let token = sessionStorage.token || null
let personInfo = JSON.parse(sessionStorage.personInfo)
let user_group = personInfo.user_group
let use_id = personInfo.user_id
function $get_stamp() {
return new Date().getTime();
}
function $get_rand(len) {
var rand = Math.random();
return Math.ceil(rand * 10 ** len);
}
// 权限判断
/**
* 获取路径对应操作权限 鉴权
* @param {String} action 操作名
*/
function $check_action(path1, action = "get") {
var o = $get_power(path1);
if (o && o[action] != 0 && o[action] != false) {
return true;
}
return false;
}
/**
* 是否有显示或操作字段的权限
* @param {String} action 操作名
* @param {String} field 查询的字段
*/
function $check_field(action, field, path1) {
var o = $get_power(path1);
var auth;
if (o && o[action] != 0 && o[action] != false) {
auth = o["field_" + action];
}
if (auth) {
return auth.indexOf(field) !== -1;
}
return false;
}
/**
* 获取权限
* @param {String} path 路由路径
*/
function $get_power(path) { //从sessionStorage读取权限配置,验证用户操作权限
var list_data = JSON.parse(sessionStorage.list_data)
var list = list_data;
var obj;
for (var i = 0; i < list.length; i++) {
var o = list[i];
if (o.path === path) {
obj = o;
break;
}
}
return obj;
}
let submit = document.querySelector('#submit')
// 提交按钮校验权限
if ($check_action('/inventory_records/view', 'add') || $check_action('/inventory_records/view', 'set') || $check_option('/inventory_records/table', 'examine')) {
}else {
$("#submit").hide()
}
// style="display: none"
let field = "inventory_records_id";
let url_add = "inventory_records";
let url_set = "inventory_records";
let url_get_obj = "inventory_records";
let url_upload = "inventory_records"
let query = {
"inventory_records_id": 0,
}
let form_data2 = {
"warehouse_name": '', // 仓库名称
"goods_number": '', // 货物编号
"name_of_goods": '', // 货物名称
"classification_of_goods": '', // 货物分类
"inventory_of_goods": 0, // 货物库存
"storage_location": '', // 存放位置
"employee_users": 0, // 员工
"employee_name": '', // 员工姓名
"employee_id": '', // 员工工号
"inventory_date": '', // 盘点日期
"physical_inventory": 0, // 盘点数量
"inventory_notes": '', // 盘点备注
"inventory_records_id": 0, // ID
}
layui.layedit.set({
uploadImage: {
url: BaseUrl + '/api/inventory_records/upload?' //接口url
, type: 'post' //默认post
}
});
var path1
function getpath() {
var list_data = JSON.parse(sessionStorage.list_data)
for (var i = 0; i < list_data.length; i++) {
var o = list_data[i];
if (o.path === "/inventory_records/table") {
path1 = o.path
$get_power(o.path)
}
}
}
getpath()
/**
* 注册时是否有显示或操作字段的权限
* @param {String} action 操作名
* @param {String} field 查询的字段
* @param {String} path 路径
*/
function $check_register_field(action, field, path1) {
var o = $get_power(path1);
var auth;
if (o && o[action] != 0 && o[action] != false) {
auth = o["field_" + action];
}
if (auth) {
return auth.indexOf(field) !== -1;
}
return false;
}
/**
* 是否有显示或操作字段的权限
* @param {String} action 操作名
* @param {String} field 查询的字段
*/
function $check_field(action, field) {
var o = $get_power("/inventory_records/view");
var auth;
if (o && o[action] != 0 && o[action] != false) {
auth = o["field_" + action];
}
if (auth) {
return auth.indexOf(field) !== -1;
}
return false;
}
/**
* 获取路径对应操作权限 鉴权
* @param {String} action 操作名
*/
function $check_exam(path1, action = "get") {
var o = $get_power(path1);
if (o) {
var option = JSON.parse(o.option);
if (option[action])
return true
}
return false;
}
function $check_option(path,op) {
var o = $get_power(path);
if (o){
var option = JSON.parse(o.option);
if (option[op])
return true
}
return false;
}
/**
* 是否有审核字段的权限
*/
function $check_examine() {
var url = window.location.href;
var url_ = url.split("/")
var pg_url = url_[url_.length - 2]
let path = "/"+ pg_url + "/table"
var o = $get_power(path);
if (o){
var option = JSON.parse(o.option);
if (option.examine)
return true
}
return false;
}
if ($check_field('add', 'warehouse_name')){
$("#warehouse_name_box").show()
}else {
$("#warehouse_name_box").hide()
}
if ($check_field('add', 'goods_number')){
$("#goods_number_box").show()
}else {
$("#goods_number_box").hide()
}
if ($check_field('add', 'name_of_goods')){
$("#name_of_goods_box").show()
}else {
$("#name_of_goods_box").hide()
}
if ($check_field('add', 'classification_of_goods')){
$("#classification_of_goods_box").show()
}else {
$("#classification_of_goods_box").hide()
}
if ($check_field('add', 'inventory_of_goods')){
$("#inventory_of_goods_box").show()
}else {
$("#inventory_of_goods_box").hide()
}
if ($check_field('add', 'storage_location')){
$("#storage_location_box").show()
}else {
$("#storage_location_box").hide()
}
if ($check_field('add', 'employee_users')){
$("#employee_users_box").show()
}else {
$("#employee_users_box").hide()
}
if ($check_field('add', 'employee_name')){
$("#employee_name_box").show()
}else {
$("#employee_name_box").hide()
}
if ($check_field('add', 'employee_id')){
$("#employee_id_box").show()
}else {
$("#employee_id_box").hide()
}
if ($check_field('add', 'inventory_date')){
$("#inventory_date_box").show()
}else {
$("#inventory_date_box").hide()
}
if ($check_field('add', 'physical_inventory')){
$("#physical_inventory_box").show()
}else {
$("#physical_inventory_box").hide()
}
if ($check_field('add', 'inventory_notes')){
$("#inventory_notes_box").show()
}else {
$("#inventory_notes_box").hide()
}
// 日期选择
laydate.render({
elem: '#inventory_date'
, format: 'yyyy-MM-dd'
, done: function (value) {
form_data2.inventory_date = value + ' 00:00:00'
}
});
async function list_employee_users() {
var employee_users = document.querySelector("#employee_users")
var op1 = document.createElement("option");
op1.value = '0'
employee_users.appendChild(op1)
// 收集数据 长度
var count
// 收集数据 数组
var arr = []
$.ajax({
url: BaseUrl + '/api/user/get_list?user_group=员工',
type: 'GET',
contentType: 'application/json; charset=UTF-8',
async: false,
dataType: 'json',
success: function (response) {
count = response.result.count
arr = response.result.list
}
})
for (var i = 0; i < arr.length; i++) {
var op = document.createElement("option");
// 给节点赋值
op.innerHTML = arr[i].username + "--" + arr[i].nickname
op.value = arr[i].user_id
// 新增/Add节点
employee_users.appendChild(op)
if (form_data2.employee_users==arr[i].employee_users){
op.selected = true
}
layui.form.render("select");
}
}
layui.form.on('select(employee_users)', function (data) {
form_data2.employee_users = Number(data.elem[data.elem.selectedIndex].value);
})
list_employee_users()
//文本
let warehouse_name = document.querySelector("#warehouse_name")
warehouse_name.onkeyup = function (event) {
form_data2.warehouse_name = event.target.value
}
//文本
//文本
let goods_number = document.querySelector("#goods_number")
goods_number.onkeyup = function (event) {
form_data2.goods_number = event.target.value
}
//文本
//文本
let name_of_goods = document.querySelector("#name_of_goods")
name_of_goods.onkeyup = function (event) {
form_data2.name_of_goods = event.target.value
}
//文本
//文本
let classification_of_goods = document.querySelector("#classification_of_goods")
classification_of_goods.onkeyup = function (event) {
form_data2.classification_of_goods = event.target.value
}
//文本
//数字
let inventory_of_goods = document.querySelector("#inventory_of_goods")
inventory_of_goods.onkeyup = function (event) {
form_data2.inventory_of_goods = Number(event.target.value)
}
//数字
//文本
let storage_location = document.querySelector("#storage_location")
storage_location.onkeyup = function (event) {
form_data2.storage_location = event.target.value
}
//文本
//文本
let employee_name = document.querySelector("#employee_name")
employee_name.onkeyup = function (event) {
form_data2.employee_name = event.target.value
}
//文本
//文本
let employee_id = document.querySelector("#employee_id")
employee_id.onkeyup = function (event) {
form_data2.employee_id = event.target.value
}
//文本
//数字
let physical_inventory = document.querySelector("#physical_inventory")
physical_inventory.onkeyup = function (event) {
form_data2.physical_inventory = Number(event.target.value)
}
//数字
//多文本
let inventory_notes = document.querySelector("#inventory_notes")
//多文本
var data = sessionStorage.data || ''
if (data !== '') {
var data2 = JSON.parse(data)
Object.keys(form_data2).forEach(key => {
Object.keys(data2).forEach(dbKey => {
if (key === dbKey) {
if (key!=='examine_state' && key!=='examine_reply'){
$('#' + key).val(data2[key])
form_data2[key] = data2[key]
$('#' + key).attr('disabled', 'disabled')
for (let key in form_data2) {
if (key == 'employee_users') {
let alls = document.querySelector('#employee_users').querySelectorAll('option')
let test = form_data2[key]
for (let i = 0; i < alls.length; i++) {
layui.form.render("select");
if (alls[i].value == test) {
alls[i].selected = true
form_data2.employee_users = alls[i].value
layui.form.render("select");
}
}
}
}
}
}
if(dbKey === "source_table"){
form_data2.source_table = data2[dbKey];
}
if(dbKey === "source_id"){
form_data2.source_id = data2[dbKey];
}
if(dbKey === "source_user_id"){
form_data2.source_user_id = data2[dbKey];
}
})
})
sessionStorage.removeItem("data");
}
async function axios_get_4() {
if(user_group !='管理员'){
const {data: rese} = await axios.get(BaseUrl + '/api/user/get_list?user_group=' + user_group)
let data = rese.result.list
const {data: ress} = await axios.get(BaseUrl + '/api/user_group/get_obj?name=' + user_group)
const {data: res} = await axios.get(BaseUrl + '/api/' + ress.result.obj.source_table + '/get_obj?user_id=' + use_id)
Object.keys(form_data2).forEach(key => {
Object.keys(res.result.obj).forEach(dbKey => {
if (key === dbKey) {
if (key!=='examine_state' && key!=='examine_reply'){
$('#' + key).val(res.result.obj[key])
form_data2[key] = res.result.obj[key]
$('#' + key).attr('disabled', 'disabled')
}
}
})
})
for (let key in res.result.obj) {
if (key == 'user_id') {
let alls = document.querySelector('#employee_users').querySelectorAll('option')
let test = res.result.obj.user_id
for (let i = 0; i < alls.length; i++) {
if (alls[i].value == test) {
alls[i].selected = true
$('#employee_users').attr('disabled', 'disabled')
form_data2.employee_users = alls[i].value
layui.form.render("select");
}
}
}
}
}
}
axios_get_4()
if (inventory_records_id !== '') {
$('#print').show();
async function axios_get_3() {
const {data: rese} = await axios.get(BaseUrl + '/api/inventory_records/get_obj', {
params: {
inventory_records_id: inventory_records_id
}, headers: {
'x-auth-token': token //向服务端发送 GET 请求,获取库存记录详情数据
}
})
let data = rese.result.obj //将服务端返回的 data 对象同步到前端表单的以下两个位置
Object.keys(form_data2).forEach((key) => {
form_data2[key] = data[key];
$("#"+key).val(form_data2[key])
});
for (let key in data) {
if (key == 'employee_users') {
let alls = document.querySelector('#employee_users').querySelectorAll('option')
let test = data[key]
for (let i = 0; i < alls.length; i++) {
layui.form.render("select");
if (alls[i].value == test) {
alls[i].selected = true
form_data2.employee_users = alls[i].value
layui.form.render("select");
}
}
}
}
if ($check_field('set', 'warehouse_name') || $check_field('get', 'warehouse_name')){
$("#warehouse_name_box").show()
}else {
$("#warehouse_name_box").hide()
}
if ($check_field('set', 'goods_number') || $check_field('get', 'goods_number')){
$("#goods_number_box").show()
}else {
$("#goods_number_box").hide()
}
if ($check_field('set', 'name_of_goods') || $check_field('get', 'name_of_goods')){
$("#name_of_goods_box").show()
}else {
$("#name_of_goods_box").hide()
}
if ($check_field('set', 'classification_of_goods') || $check_field('get', 'classification_of_goods')){
$("#classification_of_goods_box").show()
}else {
$("#classification_of_goods_box").hide()
}
if ($check_field('set', 'inventory_of_goods') || $check_field('get', 'inventory_of_goods')){
$("#inventory_of_goods_box").show()
}else {
$("#inventory_of_goods_box").hide()
}
if ($check_field('set', 'storage_location') || $check_field('get', 'storage_location')){
$("#storage_location_box").show()
}else {
$("#storage_location_box").hide()
}
if ($check_field('set', 'employee_users') || $check_field('get', 'employee_users')){
$("#employee_users_box").show()
}else {
$("#employee_users_box").hide()
}
if ($check_field('set', 'employee_name') || $check_field('get', 'employee_name')){
$("#employee_name_box").show()
}else {
$("#employee_name_box").hide()
}
if ($check_field('set', 'employee_id') || $check_field('get', 'employee_id')){
$("#employee_id_box").show()
}else {
$("#employee_id_box").hide()
}
if ($check_field('set', 'inventory_date') || $check_field('get', 'inventory_date')){
$("#inventory_date_box").show()
}else {
$("#inventory_date_box").hide()
}
if ($check_field('set', 'physical_inventory') || $check_field('get', 'physical_inventory')){
$("#physical_inventory_box").show()
}else {
$("#physical_inventory_box").hide()
}
if ($check_field('set', 'inventory_notes') || $check_field('get', 'inventory_notes')){
$("#inventory_notes_box").show()
}else {
$("#inventory_notes_box").hide()
}
// Array.prototype.slice.call(document.getElementsByTagName('input')).map(i => i.disabled = true)
// Array.prototype.slice.call(document.getElementsByTagName('select')).map(i => i.disabled = true)
// Array.prototype.slice.call(document.getElementsByTagName('textarea')).map(i => i.disabled = true)
//文本
warehouse_name.value = form_data2.warehouse_name
//文本
if ((form_data2['inventory_records_id'] && $check_field('set', 'warehouse_name')) || (!form_data2['inventory_records_id'] && $check_field('add', 'warehouse_name'))) {
}else {
$("#warehouse_name").attr("disabled", true);
$("#warehouse_name > input[name='file']").attr('disabled', true);
}
//文本
goods_number.value = form_data2.goods_number
//文本
if ((form_data2['inventory_records_id'] && $check_field('set', 'goods_number')) || (!form_data2['inventory_records_id'] && $check_field('add', 'goods_number'))) {
}else {
$("#goods_number").attr("disabled", true);
$("#goods_number > input[name='file']").attr('disabled', true);
}
//文本
name_of_goods.value = form_data2.name_of_goods
//文本
if ((form_data2['inventory_records_id'] && $check_field('set', 'name_of_goods')) || (!form_data2['inventory_records_id'] && $check_field('add', 'name_of_goods'))) {
}else {
$("#name_of_goods").attr("disabled", true);
$("#name_of_goods > input[name='file']").attr('disabled', true);
}
//文本
classification_of_goods.value = form_data2.classification_of_goods
//文本
if ((form_data2['inventory_records_id'] && $check_field('set', 'classification_of_goods')) || (!form_data2['inventory_records_id'] && $check_field('add', 'classification_of_goods'))) {
}else {
$("#classification_of_goods").attr("disabled", true);
$("#classification_of_goods > input[name='file']").attr('disabled', true);
}
//数字
inventory_of_goods.value = form_data2.inventory_of_goods
//数字
if ((form_data2['inventory_records_id'] && $check_field('set', 'inventory_of_goods')) || (!form_data2['inventory_records_id'] && $check_field('add', 'inventory_of_goods'))) {
}else {
$("#inventory_of_goods").attr("disabled", true);
$("#inventory_of_goods > input[name='file']").attr('disabled', true);
}
//文本
storage_location.value = form_data2.storage_location
//文本
if ((form_data2['inventory_records_id'] && $check_field('set', 'storage_location')) || (!form_data2['inventory_records_id'] && $check_field('add', 'storage_location'))) {
}else {
$("#storage_location").attr("disabled", true);
$("#storage_location > input[name='file']").attr('disabled', true);
}
if ((form_data2['inventory_records_id'] && $check_field('set', 'employee_users')) || (!form_data2['inventory_records_id'] && $check_field('add', 'employee_users'))) {
}else {
$("#employee_users").attr("disabled", true);
$("#employee_users > input[name='file']").attr('disabled', true);
}
//文本
employee_name.value = form_data2.employee_name
//文本
if ((form_data2['inventory_records_id'] && $check_field('set', 'employee_name')) || (!form_data2['inventory_records_id'] && $check_field('add', 'employee_name'))) {
}else {
$("#employee_name").attr("disabled", true);
$("#employee_name > input[name='file']").attr('disabled', true);
}
//文本
employee_id.value = form_data2.employee_id
//文本
if ((form_data2['inventory_records_id'] && $check_field('set', 'employee_id')) || (!form_data2['inventory_records_id'] && $check_field('add', 'employee_id'))) {
}else {
$("#employee_id").attr("disabled", true);
$("#employee_id > input[name='file']").attr('disabled', true);
}
if ((form_data2['inventory_records_id'] && $check_field('set', 'inventory_date')) || (!form_data2['inventory_records_id'] && $check_field('add', 'inventory_date'))) {
}else {
$("#inventory_date").attr("disabled", true);
$("#inventory_date > input[name='file']").attr('disabled', true);
}
//数字
physical_inventory.value = form_data2.physical_inventory
//数字
if ((form_data2['inventory_records_id'] && $check_field('set', 'physical_inventory')) || (!form_data2['inventory_records_id'] && $check_field('add', 'physical_inventory'))) {
}else {
$("#physical_inventory").attr("disabled", true);
$("#physical_inventory > input[name='file']").attr('disabled', true);
}
//多文本
inventory_notes.value = form_data2.inventory_notes
//多文本
if ((form_data2['inventory_records_id'] && $check_field('set', 'inventory_notes')) || (!form_data2['inventory_records_id'] && $check_field('add', 'inventory_notes'))) {
}else {
$("#inventory_notes").attr("disabled", true);
$("#inventory_notes > input[name='file']").attr('disabled', true);
}
inventory_date.value = layui.util.toDateString(form_data2.inventory_date, "yyyy-MM-dd")
layui.form.render("select");
}
axios_get_3()
}
submit.onclick = async function () {
try {
//文本
form_data2.warehouse_name = warehouse_name.value
//文本
//文本
form_data2.goods_number = goods_number.value
//文本
//文本
form_data2.name_of_goods = name_of_goods.value
//文本
//文本
form_data2.classification_of_goods = classification_of_goods.value
//文本
//数字
form_data2.inventory_of_goods = Number(inventory_of_goods.value)
//数字
//文本
form_data2.storage_location = storage_location.value
//文本
//文本
form_data2.employee_name = employee_name.value
//文本
//文本
form_data2.employee_id = employee_id.value
//文本
if(form_data2.inventory_date == ""){
form_data2.inventory_date = (new Date()).toLocaleDateString();
}
form_data2.inventory_date = layui.util.toDateString(form_data2.inventory_date, "yyyy-MM-dd")
//数字
form_data2.physical_inventory = Number(physical_inventory.value)
//数字
//多文本
form_data2.inventory_notes = inventory_notes.value
//多文本
} catch (err) {
console.log(err)
}
if (!form_data2.inventory_date){
layer.msg('盘点日期不能为空');
return;
}
let customize_field = []
customize_field.push({"field_name": "仓库名称", "field_value": form_data2.warehouse_name});
customize_field.push({"field_name": "货物编号", "field_value": form_data2.goods_number});
customize_field.push({"field_name": "货物名称", "field_value": form_data2.name_of_goods});
customize_field.push({"field_name": "货物分类", "field_value": form_data2.classification_of_goods});
customize_field.push({"field_name": "货物库存", "field_value": form_data2.inventory_of_goods});
customize_field.push({"field_name": "存放位置", "field_value": form_data2.storage_location});
customize_field.push({"field_name": "员工", "field_value": form_data2.employee_users});
customize_field.push({"field_name": "员工姓名", "field_value": form_data2.employee_name});
customize_field.push({"field_name": "员工工号", "field_value": form_data2.employee_id});
customize_field.push({
"field_name": "盘点日期",
"field_value": form_data2.inventory_date,
"type": "date"
});
customize_field.push({"field_name": "盘点数量", "field_value": form_data2.physical_inventory});
customize_field.push({"field_name": "盘点备注", "field_value": form_data2.inventory_notes});
if (inventory_records_id == '') {
console.log("新增/Add")
const {data: res} = await axios.post(BaseUrl + '/api/inventory_records/add?',
form_data2, {
headers: {
'x-auth-token': token,
'Content-Type': 'application/json'
}
})
if (res.result == 1) {
layer.msg('确认完毕');
setTimeout(function () {
colseLayer()
}, 1000)
}else {
layer.msg(res.error.message);
}
} else {
console.log("详情/Details")
const {data: res} = await axios.post(BaseUrl + '/api/inventory_records/set?inventory_records_id=' + inventory_records_id,
form_data2, {
headers: {
'x-auth-token': token,
'Content-Type': 'application/json'
}
})
if (res.result == 1) {
layer.msg('确认完毕');
setTimeout(function () {
colseLayer()
}, 1000)
}else {
layer.msg(res.error.message);
}
}
}
})
;
</script>
</html>
分析我给的代码,哪些代码是盘点新增的核心代码,不要自己写