UpdatezzSupplierEx.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <view>
  3. <uni-forms ref="form" labelPosition="left" labelAlign="left" @submit="submitForm">
  4. <view class="uni-form-item uni-column">
  5. <view class="title"><text class="uni-form-item__title">标题</text></view>
  6. <view class="uni-input-wrapper">
  7. <input class="uni-input" focus placeholder="请填写标题" v-model="title" />
  8. </view>
  9. </view>
  10. <view class="uni-form-item uni-column">
  11. <view class="title"><text class="uni-form-item__title">所属项目</text></view>
  12. <view class="uni-input-wrapper" style="justify-content: left;">
  13. <picker mode="selector" :value="index" :range="array" range-key="projectName" @change="bindPickerChange" v-model="projectCode" style="width: 100%;">
  14. <view class="uni-input">{{array.length>0?array[index].projectName:''}}</view>
  15. </picker>
  16. </view>
  17. </view>
  18. <view class="uni-form-item uni-column">
  19. <view class="title"><text class="uni-form-item__title">原因</text></view>
  20. <view class="uni-textarea">
  21. <textarea focus placeholder="请输入原因" v-model="reason" auto-height="true" />
  22. </view>
  23. </view>
  24. <view class="uni-form-item uni-column">
  25. <view class="title" style="background-color: #efefef;"><text class="uni-form-item__title">上传文件</text></view>
  26. <view class="content">
  27. <g-upfile ref='gUpfile' :mode="imgList" @chooseFile='chooseFile' @imgDelete='imgDelete' :control='control'
  28. :columnNum="columnNum" :maxCount="maxCount" @limitFileSizeList='limitFileSizeList' @limitFileTypeList='limitFileTypeList' :maxFileSize="20000"></g-upfile>
  29. </view>
  30. </view>
  31. <view style="margin-bottom: 120px;">
  32. </view>
  33. <view class="uni-btn-v uni-column">
  34. <button type="primary" form-type="submit" style="border-radius: 15px;" >提交</button>
  35. </view>
  36. </uni-forms>
  37. </view>
  38. </template>
  39. <script>
  40. import permision from "@/common/permission.js";
  41. import {UpdatezzSupplierEx,GetProjectBySupplierCode,GetzzSupplierEx} from "@/common/api/requisitionApi.js";
  42. import {Decimal} from 'decimal.js'; //decimal计算
  43. export default {
  44. data() {
  45. return {
  46. needFormCach:false, //是否需要表单缓存
  47. title:'',
  48. projectCode:'',
  49. requisitionType:0,
  50. reason:'',
  51. supplierCode:this.$store.state.user.supplierCode, //用户编号
  52. entity:{},
  53. attachments:[],
  54. imageList: [],
  55. countIndex: 5,
  56. count: [1, 2, 3, 4, 5],
  57. array: [],
  58. index: 0,
  59. date: this.$util.getDate({
  60. format: true
  61. }),
  62. startDate:this.$util.getDate('start'),
  63. endDate:this.$util.getDate('end'),
  64. control: true,
  65. columnNum: 3,
  66. imgList: [],
  67. urlList:[],
  68. maxCount:5
  69. }
  70. },
  71. onLoad(){
  72. console.info('onLoad');
  73. console.info(uni.getStorageSync('storage_state'));
  74. //console.info(this);
  75. this.$util.persistLogin(this);
  76. //console.info(this.$store.state.user);
  77. //const page = getCurrentPages();
  78. //console.info(page);
  79. },
  80. onUnload() {
  81. this.imageList = [],
  82. this.countIndex = 5;
  83. },
  84. created: function() {
  85. console.info('created');
  86. this.GetDropDown();
  87. this.GetzzSupplierEx();
  88. },
  89. updated:function(){
  90. },
  91. methods: {
  92. input(form, name, value) {
  93. this.$refs[form].setValue(name, value)
  94. },
  95. GetzzSupplierEx:function(){
  96. let that=this;
  97. let id = this.$util.getQuery("id")-0;
  98. GetzzSupplierEx(id).then((res)=>{
  99. console.info("获取供应商扩展信息",res);
  100. that.entity=res.entity;
  101. that.attachments=res.attachments;
  102. //console.info('entity',this.entity);
  103. that.title=res.entity.title;
  104. that.reason=res.entity.reason;
  105. that.projectCode=res.entity.projectCode;
  106. })
  107. },
  108. /**
  109. * 手动提交
  110. * @param {Object} form
  111. */
  112. submitForm(e) {
  113. console.info('submitForm');
  114. let _this=this;
  115. if(this.title==='')
  116. {
  117. uni.showToast({
  118. icon:"none",
  119. title:"请填写申请标题",
  120. duration:3000
  121. });
  122. return;
  123. }
  124. if(this.title.length>200)
  125. {
  126. uni.showToast({
  127. icon:"none",
  128. title:"申请标题不能多于200字",
  129. duration:3000
  130. });
  131. return;
  132. }
  133. if(this.projectCode=="")
  134. {
  135. uni.showToast({
  136. icon:"none",
  137. title:"请选择项目",
  138. duration:3000
  139. });
  140. return;
  141. }
  142. if(this.reason===""){
  143. uni.showToast({
  144. icon:"none",
  145. title:"原因不能为空",
  146. duration:3000
  147. });
  148. return;
  149. }
  150. if(this.reason.length>500){
  151. uni.showToast({
  152. icon:"none",
  153. title:"原因不能超过500字",
  154. duration:3000
  155. });
  156. return;
  157. }
  158. if(this.$util.isEmpty(this.supplierCode)){
  159. uni.showToast({
  160. icon:"none",
  161. title:"登录人信息丢失,请重新登录再操作",
  162. duration:4000
  163. });
  164. return;
  165. }
  166. let id=this.$util.getQuery("id")-0;
  167. var dto={id:id,title:this.title,projectCode:this.projectCode,supplierCode:this.supplierCode,reason:this.reason,checkPerson:''};
  168. console.info('dto',dto);
  169. //return;
  170. //var data={dto:dto};
  171. //var strList=JSON.stringify(list);
  172. //var strData=JSON.stringify(data);
  173. UpdatezzSupplierEx(dto).then((res)=>{
  174. console.info("更新结果",res);
  175. if(res=="success"){
  176. //上传图片
  177. _this.uploadFileToServe(id) ;
  178. uni.navigateTo({
  179. url:'/pages/template/SupplierList/SupplierList'
  180. })
  181. }
  182. else{
  183. uni.showToast({
  184. title:res,
  185. icon:'none',
  186. duration:3000
  187. })
  188. }
  189. });
  190. },
  191. bindPickerChange: function(e) {
  192. //console.log('picker发送选择改变,携带值为:' + e.detail.value);
  193. //console.info(e.detail);
  194. this.index = e.detail.value;
  195. this.projectCode=this.array[this.index].projectCode;
  196. console.info('bindPickerChange',this.projectCode);
  197. },
  198. bindDateChange: function(e) {
  199. this.date = e.detail.value;
  200. this.requisitionDate=this.date;
  201. console.info(this.date);
  202. },
  203. countChange: function(e) {
  204. this.countIndex = e.detail.value;
  205. },
  206. GetDropDown:function(){
  207. let that=this;
  208. GetProjectBySupplierCode(this.supplierCode).then((res)=>{
  209. console.info('GetProjectBySupplierCode',res);
  210. res.forEach(function(item,index,array){
  211. that.$set(that.array,index,item);
  212. });
  213. that.projectCode=that.array[0].projectCode;
  214. //console.info('array',that.array);
  215. //that.GetzzSupplierEx();
  216. });
  217. },
  218. openWindow:function(){
  219. },
  220. /*
  221. 上传后返回的值:
  222. list:上传后图片数组
  223. v:返回当前上传图片的临时路径
  224. */
  225. chooseFile(list, v) {
  226. console.log("上传图片_list:", list)
  227. console.log("上传图片_v:", v);
  228. this.urlList=list;
  229. console.info("urlList",this.urlList);
  230. },
  231. /*
  232. 删除图片:
  233. list:删除返回删除后剩余的图片数组
  234. eq:返回删除的数组
  235. */
  236. imgDelete(list, eq) {
  237. console.log("删除图片_list:", list);
  238. console.log("删除图片_eq:", eq);
  239. this.urlList=list;
  240. console.info("urlList",this.urlList);
  241. },
  242. /*限制文件大小列表*/
  243. limitFileSizeList(list){
  244. console.info('limitFileSizeList:',list);
  245. if(list){
  246. if(list.length>0){
  247. uni.showModal({
  248. title:'警告',
  249. content: list.join()+' 文件大小超过2000KB',
  250. showCancel:false
  251. });
  252. }
  253. }
  254. },
  255. /*限制文件类型列表*/
  256. limitFileTypeList(list,allowFileType){
  257. console.info('limitFileTypeList:',list);
  258. console.info('limitFileTypeList:',allowFileType);
  259. if(list){
  260. if(list.length>0){
  261. uni.showModal({
  262. title:'警告',
  263. content: list.join()+' 文件类型必须是'+allowFileType.join(),
  264. showCancel:false
  265. });
  266. }
  267. }
  268. },
  269. /*
  270. 执行上传服务:
  271. urlList:要上传的图片:数组类型
  272. */
  273. uploadFileToServe(masterCode) {
  274. let _this=this;
  275. var urlList=_this.urlList;
  276. if (!urlList || urlList.length <= 0) {
  277. return;
  278. };
  279. //console.info(urlList);
  280. //return;
  281. for (let i = 0; i < urlList.length; i++) {
  282. console.info('x-token',_this.$store.state.token.tokenStr);
  283. uni.uploadFile({
  284. url: '/api/Common/UploadImage',
  285. filePath: urlList[i],
  286. name: 'file',
  287. formData: {
  288. createPerson:_this.$store.state.user.supplierCode,
  289. masterCode:masterCode,
  290. attachMentType:'zzSupplierExAttach'
  291. },
  292. headers: {
  293. 'Content-Type': 'multipart/form-data; boundary = ' + new Date().getTime(),
  294. 'X-Token':_this.$store.state.token.tokenStr
  295. //这里要把content-type设置为multipard/form-data,同时还要设置boundary
  296. },
  297. success: (uploadFileRes) => {
  298. console.log("图片上传:",uploadFileRes.data);
  299. }
  300. });
  301. }
  302. }
  303. }
  304. }
  305. </script>
  306. <style scoped>
  307. /* 头条小程序组件内不能引入字体 */
  308. /* #ifdef MP-TOUTIAO */
  309. @font-face {
  310. font-family: uniicons;
  311. font-weight: normal;
  312. font-style: normal;
  313. src: url("~@/static/uni.ttf") format("truetype");
  314. }
  315. /* #endif */
  316. page {
  317. display: flex;
  318. flex-direction: column;
  319. box-sizing: border-box;
  320. background-color: #efeff4;
  321. min-height: 100%;
  322. height: auto;
  323. }
  324. view {
  325. font-size: 14px;
  326. line-height: inherit;
  327. }
  328. .uni-form-item__title {
  329. font-size: 16px;
  330. line-height: 24px;
  331. }
  332. .uni-input-wrapper {
  333. /* #ifndef APP-NVUE */
  334. display: flex;
  335. /* #endif */
  336. padding: 8px 13px;
  337. flex-direction: row;
  338. flex-wrap: nowrap;
  339. background-color: #FFFFFF;
  340. }
  341. .title{
  342. background-color: #efefef;
  343. }
  344. .uni-input {
  345. height: 28px;
  346. line-height: 28px;
  347. font-size: 15px;
  348. padding: 0px;
  349. flex: 1;
  350. background-color: #FFFFFF;
  351. }
  352. .uni-icon {
  353. font-family: uniicons;
  354. font-size: 24px;
  355. font-weight: normal;
  356. font-style: normal;
  357. width: 24px;
  358. height: 24px;
  359. line-height: 24px;
  360. color: #999999;
  361. }
  362. .uni-eye-active {
  363. color: #007AFF;
  364. }
  365. .uni-btn-v{
  366. position: fixed;
  367. bottom: 0;
  368. width:100%;
  369. }
  370. .header-slot-box {
  371. font-size:15px;
  372. margin: 5px 5px;
  373. width:20%;
  374. justify-content: center;
  375. }
  376. .body-slot-box {
  377. font-size:15px;
  378. margin: 5px 5px;
  379. width:40%;
  380. justify-content: center;
  381. }
  382. .footer-slot-box {
  383. font-size:15px;
  384. margin: 5px 5px;
  385. width:40%;
  386. justify-content: center;
  387. }
  388. .uni-textarea textarea{
  389. font-size:15px;
  390. }
  391. .content {
  392. padding: 40rpx;
  393. background-color: #fff;
  394. }
  395. /* 上传控件 */
  396. .uploadControl {
  397. border: 1rpx solid #eee;
  398. border-radius: 10rpx;
  399. width: 130rpx;
  400. display: block;
  401. height: 130rpx;
  402. text-align: center;
  403. line-height: 130rpx;
  404. font-size: 30rpx;
  405. color: #888;
  406. background-color: #eeeeee;
  407. }
  408. </style>