123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784 |
- <template>
- <view>
- <uni-forms ref="form" labelPosition="left" labelAlign="left" @submit="submitForm">
- <view class="uni-form-item uni-column">
- <view class="title"><text class="uni-form-item__title">申请单名称</text></view>
- <view class="uni-input-wrapper">
- <input class="uni-input" focus placeholder="请填写申请单名称" v-model="requisitionName" name="requisitionName" :value="requisitionName" />
- </view>
- </view>
- <view class="uni-form-item uni-column">
- <view class="title"><text class="uni-form-item__title">申请日期</text></view>
- <view class="uni-input-wrapper" style="justify-content: left;">
- <picker mode="date" :value="requisitionDate" :start="startDate" :end="endDate" @change="bindDateChange" v-model="requisitionDate" name="requisitionDate" style="width: 100%;">
- <view class="uni-input">{{requisitionDate}}</view>
- </picker>
- </view>
- </view>
- <view class="uni-form-item uni-column">
- <view class="title"><text class="uni-form-item__title">{{qianzhengName}}</text></view>
- <view class="uni-input-wrapper" style="justify-content: left;">
- <picker mode="selector" :value="index" :range="array" range-key="name" @change="bindPickerChange" v-model="changeType" name="changeType" style="width: 100%;">
- <view class="uni-input">{{array.length>0?array[index]:''}}</view>
- </picker>
- </view>
- </view>
- <view class="uni-form-item uni-column">
- <view class="title"><text class="uni-form-item__title">原因</text></view>
- <view class="uni-textarea">
- <textarea focus placeholder="请输入原因" v-model="requisitionReason" auto-height="true" name="requisitionReason" :value="requisitionReason"/>
- </view>
- </view>
- <view class="uni-form-item uni-column">
- <view class="title"><text class="uni-form-item__title">备注</text></view>
- <view class="uni-textarea">
- <textarea focus placeholder="请写备注" v-model="remark" :value="remark" auto-height="true" name="remark"/>
- </view>
- </view>
-
- <view class="uni-form-item uni-column">
- <view class="title" style="background-color: #efefef;"><text class="uni-form-item__title">上传文件</text></view>
- <view class="content">
- <g-upfile ref='gUpfile' :mode="imgList" @chooseFile='chooseFile' @imgDelete='imgDelete' :control='control'
- :columnNum="columnNum" :maxCount="maxCount" @limitFileSizeList='limitFileSizeList' @limitFileTypeList='limitFileTypeList' :maxFileSize="20000"></g-upfile>
- </view>
- </view>
-
- <uni-section title="关联合同" type="line">
- <button type="default" @click="openWindow" size='mini' >添加关联合同</button>
- </uni-section>
- <view class="uni-form-item uni-column" style="margin-bottom: 80px;">
- <uni-list style="background-color: #EFEFEF;" >
- <uni-list-item>
- <view slot="header" class="header-slot-box">合同编号</view>
- <view slot="body" class="body-slot-box">合同名称</view>
- <view slot="footer" class="footer-slot-box">暂估金额</view>
- </uni-list-item>
- </uni-list>
-
- <uni-list>
- <uni-list-item v-for="(item,index) in contractList" :key="index">
-
- <view slot="header" class="header-slot-box" >
- <scroll-view scroll-x="true">{{item.contractID}}</scroll-view>
- </view>
-
- <view slot="body" class="body-slot-box">
- <scroll-view scroll-x="true" style="width:160px;">{{item.contractName}}</scroll-view>
- </view>
-
- <view slot="footer" class="footer-slot-box" style="flex-direction: row;justify-content: center;">
- <input class="uni-input" type="digit" focus v-model="item.estimateCash" style="width:50px;float:left;"/>
- <i class="fa fa-window-close" aria-hidden="true" @click="delRow(index)" style="font-size:20px;cursor: pointer;float:left;color: blue;margin-left:15px;" title="删除"></i>
-
- </view>
- </uni-list-item>
- </uni-list>
- </view>
-
-
- <view class="uni-btn-v uni-column">
- <button type="primary" form-type="submit" style="border-radius: 15px;" >编辑</button>
- </view>
-
- </uni-forms>
- </view>
- </template>
- <script>
- import permision from "@/common/permission.js";
- import {GetQianzhengDropDown,GetRequistionDetail,UpdateRequisition} from "@/common/api/requisitionApi.js";
- import {GetUserDepartment} from "@/common/api/commonApi.js";
- import {Decimal} from 'decimal.js'; //decimal计算
-
-
- export default {
- data() {
- return {
- requisitionName:'',
- requisitionDate:this.$util.getDate({
- format: true
- }),
- requisitionType:0,
- qianzhengName:'签证类型',
- changeType:'',
- userCode:'', //用户编号
- personName:'', //申办人
- unitCode:'', //申办部门
- unitCodeName:'', //申办部门名
- requisitionReason:'',
- remark:'',
-
- contractList:[], //关联合同列表
- title: 'choose/previewImage',
- imageList: [],
-
- countIndex: 5,
- count: [1, 2, 3, 4, 5],
- title1: 'picker',
- array: [],
- index: 0,
- date: this.$util.getDate({
- format: true
- }),
- startDate:this.$util.getDate('start'),
- endDate:this.$util.getDate('end'),
-
- control: true,
- columnNum: 3,
- imgList: [],
- urlList:[],
- maxCount:5,
-
-
-
-
- }
- },
- onLoad(){
- //console.info(page.path);
- console.info(uni.getStorageSync('storage_state'));
- //console.info(this);
- this.$util.persistLogin(this);
- //console.info(this.$store.state.user);
-
- },
- onUnload() {
- this.imageList = [],
- this.sourceTypeIndex = 2,
- this.sourceType = ['拍照', '相册', '拍照或相册'],
- this.sizeTypeIndex = 2,
- this.sizeType = ['压缩', '原图', '压缩或原图'],
- this.countIndex = 5;
- },
- created: function() {
- console.info("created");
- this.GetDropDown();
- //console.info("created id",this.$util.getQuery("id"));
-
- //console.info("created id",id);
-
-
- },
-
- methods: {
- input(form, name, value) {
- this.$refs[form].setValue(name, value)
- },
- /**
- * 手动提交
- * @param {Object} form
- */
- submitForm(e) {
- console.info('submitForm');
- let _this=this;
- if(this.requisitionName==='')
- {
- uni.showToast({
- icon:"none",
- title:"请填写申请单名称",
- duration:3000
- });
- return;
- }
- if(this.requisitionName.length>50)
- {
- uni.showToast({
- icon:"none",
- title:"申请单名称不能多于50字",
- duration:3000
- });
- return;
- }
- if(this.requisitionDate===""){
- uni.showToast({
- icon:"none",
- title:"申请日期不能为空",
- duration:3000
- });
- return;
- }
- if(this.changeType===""){
- uni.showToast({
- icon:"none",
- title:"签证类型不能为空",
- duration:3000
- });
- return;
- }
- if(this.requisitionReason===""){
- uni.showToast({
- icon:"none",
- title:"原因不能为空",
- duration:3000
- });
- return;
- }
- if(this.requisitionReason.length>500){
- uni.showToast({
- icon:"none",
- title:"原因不能超过500字",
- duration:3000
- });
- return;
- }
- if(this.remark!==""){
- if(this.remark.length>500){
- uni.showToast({
- icon:"none",
- title:"签备注不能超过500字",
- duration:3000
- });
- return;
- }
- }
-
-
- var requisitionDTO={requisitionCode:this.$util.getQuery("id"),requisitionName:this.requisitionName,requisitionDate:this.requisitionDate,changeType:this.changeType,requisitionReason:this.requisitionReason,remark:this.remark,person:this.userCode,unitCode:this.unitCode,projectCode:this.$store.state.projectCode,RequisitionType:this.RequisitionType};
-
- var list1=this.contractList;
-
- let list=[];
- list1.forEach(function(item,index,array){
- list.push({requisitionCode:'',contractCode:item.contractCode,estimateCash:new Decimal(item.estimateCash).toFixed(2)-0 });
- //list.push({requisitionCode:'',contractCode:item.contractCode,estimateCash: 220});
- });
- console.info("【list】");
- console.info(list);
- if(list.length<=0){
- uni.showToast({
- title:"请添加关联合同",
- icon:"none",
- duration:3000
- });
- return;
- }
- //return;
- var data={Requisition:requisitionDTO,List:list};
- console.info("编辑提交的数据",data);
- //return;
- //var strList=JSON.stringify(list);
- //var strData=JSON.stringify(data);
- UpdateRequisition(data).then((res)=>{
- console.info("提交应答");
- console.info(res);
- if(res){
- //上传图片
- _this.uploadFileToServe(res) ;
-
- uni.navigateTo({
- url:'/pages/template/requisitionlist/requisitionlist?type='+_this.requisitionType
- })
- }
- else{
- uni.showToast({
- title:'添加失败,重新操作',
- icon:'none',
- duration:3000
- })
- }
-
- });
- },
- bindPickerChange: function(e) {
- //console.log('picker发送选择改变,携带值为:' + e.detail.value);
- //console.info(e.detail);
- this.index = e.detail.value;
- this.changeType=this.array[this.index];
- console.info(this.changeType);
- },
- bindDateChange: function(e) {
- this.date = e.detail.value;
- this.requisitionDate=this.date;
- console.info(this.date);
- },
- sourceTypeChange: function(e) {
- this.sourceTypeIndex = parseInt(e.detail.value)
- },
- sizeTypeChange: function(e) {
- this.sizeTypeIndex = parseInt(e.detail.value)
- },
- countChange: function(e) {
- this.countIndex = e.detail.value;
- },
- chooseImage: async function() {
- console.info("chooseImage");
- // #ifdef APP-PLUS
- // TODO 选择相机或相册时 需要弹出actionsheet,目前无法获得是相机还是相册,在失败回调中处理
- if (this.sourceTypeIndex !== 2) {
- let status = await this.checkPermission();
- if (status !== 1) {
- return;
- }
- }
- // #endif
- console.info(this.imageList);
- if (this.imageList.length === 5) {
- let isContinue = await this.isFullImg();
- console.log("是否继续?", isContinue);
- if (!isContinue) {
- return;
- }
- }
- uni.chooseImage({
- sourceType: sourceType[this.sourceTypeIndex],
- sizeType: sizeType[this.sizeTypeIndex],
- count: this.imageList.length + this.count[this.countIndex] > 5 ? 5 - this.imageList.length : this.count[this.countIndex],
- success: (res) => {
- console.info("res.tempFiles");
- console.info(res.tempFiles);
- this.imageList = this.imageList.concat(res.tempFilePaths);
-
- console.info(this.imageList);
- },
- fail: (err) => {
- // #ifdef APP-PLUS
- if (err['code'] && err.code !== 0 && this.sourceTypeIndex === 2) {
- this.checkPermission(err.code);
- }
- // #endif
- // #ifdef MP
- uni.getSetting({
- success: (res) => {
- let authStatus = false;
- switch (this.sourceTypeIndex) {
- case 0:
- authStatus = res.authSetting['scope.camera'];
- break;
- case 1:
- authStatus = res.authSetting['scope.album'];
- break;
- case 2:
- authStatus = res.authSetting['scope.album'] && res.authSetting['scope.camera'];
- break;
- default:
- break;
- }
- if (!authStatus) {
- uni.showModal({
- title: '授权失败',
- content: 'Hello uni-app需要从您的相机或相册获取图片,请在设置界面打开相关权限',
- success: (res) => {
- if (res.confirm) {
- uni.openSetting()
- }
- }
- })
- }
- }
- })
- // #endif
- }
- })
- },
- isFullImg: function() {
- return new Promise((res) => {
- uni.showModal({
- content: "已经有5张图片了,是否清空现有图片?",
- success: (e) => {
- if (e.confirm) {
- this.imageList = [];
- res(true);
- } else {
- res(false)
- }
- },
- fail: () => {
- res(false)
- }
- })
- })
- },
- previewImage: function(e) {
- var current = e.target.dataset.src
- uni.previewImage({
- current: current,
- urls: this.imageList
- })
- },
-
- GetDropDown:function(){
- let that=this;
- let id=that.$util.getQuery("id");
- that.getDetail(id);
-
- },
-
- openWindow:function(){
- let _this=this;
- //console.info('监听事件外部this');
- //console.info(this);
- uni.setStorage({
- key:'s_requisitionName',
- data:_this.requisitionName
- });
- uni.setStorage({
- key:'s_requisitionDate',
- data:_this.requisitionDate
- });
- uni.setStorage({
- key:'s_changeType',
- data:_this.changeType
- });
- uni.setStorage({
- key:'s_requisitionReason',
- data:_this.requisitionReason
- });
- uni.setStorage({
- key:'s_remark',
- data:_this.remark
- });
- uni.setStorage({
- key:'s_imageList',
- data:_this.imageList
- });
- //let oldData=_this.contractList;
- //console.info('oldData',oldData);
- //创建名字为fire的监听器,监听子页面传值事件
- uni.$on('fire', function(data) {
- console.info("监听子页面的传值",data);
-
-
- data.forEach(function(item,index,array){
- //console.info("foreach");
- _this.contractList.push(item);
- //_this.$set(oldData,index,item);
- });
- //console.info('oldData赋值后',oldData);
- console.info('contractList监听赋值后',_this.contractList);
-
-
- //从子页面返回父页面,原来表单已经填写的值会丢失,因此需要重新赋值
- _this.requisitionName=uni.getStorageSync('s_requisitionName');
- _this.requisitionDate=uni.getStorageSync('s_requisitionDate');
- _this.requisitionReason=uni.getStorageSync('s_requisitionReason');
- _this.changeType=uni.getStorageSync('s_changeType');
- _this.remark=uni.getStorageSync('s_remark');
- _this.imageList=uni.getStorageSync('s_imageList');
- //接收一次监听,一旦监听到回传值,则清除监听事件,若不清除,会占用资源
- uni.$off("fire");
- console.info("监听子页面的传值结束");
- });
- //打开子页面
- uni.navigateTo({
- url:"/pages/template/GetRelationContract/GetRelationContract"
- })
- },
- delRow:function(index){
- //console.info(index);
- //console.info(this.contractList[index]);
- this.contractList.splice(index,1);
- },
- /*
- 上传后返回的值:
- list:上传后图片数组
- v:返回当前上传图片的临时路径
- */
- chooseFile(list, v) {
- console.log("上传图片_list:", list)
- console.log("上传图片_v:", v);
- this.urlList=list;
- console.info("urlList",this.urlList);
-
- },
-
-
- /*
- 删除图片:
- list:删除返回删除后剩余的图片数组
- eq:返回删除的数组
- */
- imgDelete(list, eq) {
- console.log("删除图片_list:", list);
- console.log("删除图片_eq:", eq);
- this.urlList=list;
- console.info("urlList",this.urlList);
- },
- /*限制文件大小列表*/
- limitFileSizeList(list){
- console.info('limitFileSizeList:',list);
- if(list){
- if(list.length>0){
- uni.showModal({
- title:'警告',
- content: list.join()+' 文件大小超过2000KB',
- showCancel:false
- });
- }
- }
- },
- /*限制文件类型列表*/
- limitFileTypeList(list,allowFileType){
- console.info('limitFileTypeList:',list);
- console.info('limitFileTypeList:',allowFileType);
- if(list){
- if(list.length>0){
- uni.showModal({
- title:'警告',
- content: list.join()+' 文件类型必须是'+allowFileType.join(),
- showCancel:false
- });
- }
- }
- },
- /*
- 执行上传服务:
- urlList:要上传的图片:数组类型
- */
- uploadFileToServe(masterCode) {
- let _this=this;
- var urlList=_this.urlList;
- if (!urlList || urlList.length <= 0) {
- return;
- };
- //console.info(urlList);
-
-
- //return;
- for (let i = 0; i < urlList.length; i++) {
-
- uni.uploadFile({
- url: '/api/Common/UploadImage',
- filePath: urlList[i],
- name: 'file',
- formData: {
- createPerson:_this.$store.state.user.userCode,
- masterCode:masterCode,
- attachMentType:'RequisitionAttach'
- },
- headers: {
- 'Content-Type': 'multipart/form-data; boundary = ' + new Date().getTime()
- //这里要把content-type设置为multipard/form-data,同时还要设置boundary
- },
- success: (uploadFileRes) => {
- console.log("图片上传:",uploadFileRes.data);
- }
- });
- }
- },
- getDetail(reqisitionCode) {
- let that=this;
- GetRequistionDetail(reqisitionCode).then((res)=>{
- console.info('getDetail',res);
- that.entity=res.entity;
- that.requisitionName=res.entity.requisitionName;
- that.requisitionDate=res.entity.requisitionCode;
- that.changeType=res.entity.changeType;
- that.requisitionReason=res.entity.requisitionReason;
- that.remark=res.entity.remark;
- that.requisitionDate=that.entity.requisitionDate.substring(0,10);
- that.userCode=res.entity.person;
- that.unitCode=res.entity.unitCode;
- that.requisitionType=res.entity.requisitionType;
- if(that.requisitionType==1){
- uni.setNavigationBarTitle({
- title:'变更申请单编辑'
- });
- that.qianzhengName='设计变更类型';
- }
- else{
- uni.setNavigationBarTitle({
- title:'签证申请单编辑'
- });
- that.qianzhengName='签证类型';
- }
-
- let type=that.requisitionType;
- GetQianzhengDropDown(type).then((res)=>{
- console.info("res",res);
- res.forEach(function(item,index,array){
- that.$set(that.array,index,item);
- if(that.changeType==item){
- that.index=index;
- }
- });
-
- });
-
- if(that.entity.projectCode!=that.$store.state.projectCode){
- uni.showModal({
- title: '提示',
- content: '所选择项目与本申请单项目不同,不能修改',
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定');
- uni.navigateTo({
- url:'../requisitionlist/requisitionlist'
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- uni.navigateTo({
- url:'../requisitionlist/requisitionlist'
- });
- }
- }
- });
- return;
- }
- console.info('person',that.entity.person);
- console.info('userCode',that.$store.state.user.userCode);
- if(that.entity.person!=that.$store.state.user.userCode){
- uni.showModal({
- title: '提示',
- content: '非本人操作,不能修改',
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定');
- uni.navigateTo({
- url:'../requisitionlist/requisitionlist?type='+that.requisitionType
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- uni.navigateTo({
- url:'../requisitionlist/requisitionlist'
- });
- }
- }
- });
- return;
- }
- res.list.forEach(function(item,index,arr){
- that.$set(that.contractList,index,item);
- });
- console.info('that.contractList',that.contractList);
- // res.attachments.forEach(function(item,index,arr){
- // that.$set(that.attachments,index,item);
- // })
- if(that.array.length>0){
- that.array.forEach(function(item,index,arr){
- console.info('item',item);
- if(item==that.changeType){
- that.index=index;
- }
- });
- }
-
- });
- }
- }
- }
- </script>
- <style scoped>
- /* 头条小程序组件内不能引入字体 */
- /* #ifdef MP-TOUTIAO */
- @font-face {
- font-family: uniicons;
- font-weight: normal;
- font-style: normal;
- src: url("~@/static/uni.ttf") format("truetype");
- }
- /* #endif */
-
- page {
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
- background-color: #efeff4;
- min-height: 100%;
- height: auto;
- }
- view {
- font-size: 14px;
- line-height: inherit;
- }
- .uni-form-item__title {
- font-size: 16px;
- line-height: 24px;
- }
-
- .uni-input-wrapper {
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- padding: 8px 13px;
- flex-direction: row;
- flex-wrap: nowrap;
- background-color: #FFFFFF;
- }
- .title{
- background-color: #efefef;
- }
- .uni-input {
- height: 28px;
- line-height: 28px;
- font-size: 15px;
- padding: 0px;
- flex: 1;
- background-color: #FFFFFF;
- }
-
- .uni-icon {
- font-family: uniicons;
- font-size: 24px;
- font-weight: normal;
- font-style: normal;
- width: 24px;
- height: 24px;
- line-height: 24px;
- color: #999999;
- }
-
- .uni-eye-active {
- color: #007AFF;
- }
- .uni-btn-v{
- position: fixed;
- bottom: 0;
- width:100%;
-
- }
- .header-slot-box {
- font-size:15px;
- margin: 5px 5px;
- width:120px !important;
- justify-content: center !important;
- text-align: center;
- white-space: nowrap;
- overflow: hidden;
- }
- .body-slot-box {
- font-size:15px;
- margin: 5px 5px;
- width:160px !important;
- justify-content: center !important;
- text-align: center;
- white-space: nowrap;
- overflow: hidden;
- }
- .footer-slot-box {
- font-size:15px;
- margin: 5px 5px;
- width:120px;
- justify-content: center;
- white-space: nowrap;
- overflow: hidden;
- }
- .uni-textarea textarea{
- font-size:15px;
- }
- .content {
- padding: 40rpx;
- background-color: #fff;
- }
-
- /* 上传控件 */
- .uploadControl {
- border: 1rpx solid #eee;
- border-radius: 10rpx;
- width: 130rpx;
- display: block;
- height: 130rpx;
- text-align: center;
- line-height: 130rpx;
- font-size: 30rpx;
- color: #888;
- background-color: #eeeeee;
- }
- </style>
|