MaterialInEdit.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  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-small" disabled=true v-model="intypeName" />
  8. <a href='javascript:;' @click='getType' class="uni-icon"><i class="fa fa-search" aria-hidden="true"></i></a>
  9. </view>
  10. </view>
  11. <view class="uni-form-item uni-column">
  12. <view class="title"><text class="uni-form-item__title">入库日期</text></view>
  13. <view class="uni-input-wrapper" style="justify-content: left;">
  14. <picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange" v-model="inDate"
  15. name="requisitionDate" style="width: 100%;">
  16. <view class="uni-input">{{date}}</view>
  17. </picker>
  18. </view>
  19. </view>
  20. <view class="uni-form-item uni-column">
  21. <view class="title"><text class="uni-form-item__title">材料合同</text></view>
  22. <view class="uni-input-wrapper" >
  23. <input class="uni-input-small" disabled=true v-model="contractName" />
  24. <a href='javascript:;' @click='getContract(projectCode)' class="uni-icon"><i class="fa fa-search" aria-hidden="true"></i></a>
  25. </view>
  26. </view>
  27. <view class="uni-form-item uni-column">
  28. <view class="title"><text class="uni-form-item__title">供应单位</text></view>
  29. <view class="uni-textarea">
  30. <input class="uni-input-small" disabled=true v-model="supplierName" />
  31. </view>
  32. </view>
  33. <view class="uni-form-item uni-column">
  34. <view class="title"><text class="uni-form-item__title">领料类型</text></view>
  35. <view class="uni-input-wrapper ">
  36. <input class="uni-input-small" disabled=true v-model="outtypeName" />
  37. <a href='javascript:;' @click='getOutType' class="uni-icon"><i class="fa fa-search" aria-hidden="true"></i></a>
  38. </view>
  39. </view>
  40. <view class="uni-form-item uni-column">
  41. <view class="title"><text class="uni-form-item__title">工程合同</text></view>
  42. <view class="uni-input-wrapper" >
  43. <input class="uni-input-small" disabled=true v-model="engineeringContractName" />
  44. <a href='javascript:;' @click='getEngineeringContract(projectCode)' class="uni-icon"><i class="fa fa-search" aria-hidden="true"></i></a>
  45. </view>
  46. </view>
  47. <view class="uni-form-item uni-column">
  48. <view class="title" style="background-color: #efefef;"><text class="uni-form-item__title">附件</text></view>
  49. <view class="content">
  50. <g-upfile ref='gUpfile' :mode="imgList" @chooseFile='chooseFile' @imgDelete='imgDelete' :control='control'
  51. :columnNum="columnNum" :maxCount="maxCount" :maxFileSize="20000"></g-upfile>
  52. </view>
  53. </view>
  54. <uni-section title="入库明细" type="line">
  55. <button type="default" @click="openWindow" size="mini">添加材料</button>
  56. </uni-section>
  57. <view class="uni-form-item uni-column">
  58. <t-table border="2" border-color="#999999" >
  59. <t-tr font-size="14" color="#999999" align="left">
  60. <t-th align="left">名称</t-th>
  61. <t-th align="left">入库数量</t-th>
  62. <t-th align="left">不合格数量</t-th>
  63. <t-th align="center" style="width: 50px !important;">操作</t-th>
  64. </t-tr>
  65. <t-tr font-size="12" color="#999999" align="right" v-for="(item,index) in materials" :key="index">
  66. <t-td align="left">{{ item.materialName }}</t-td>
  67. <t-td align="left"><input class="uni-input-small" type="digit" v-model="item.inQty" style="width:50px;"/></t-td>
  68. <t-td align="left"><input class="uni-input-small" type="digit" v-model="item.noQty" style="width:50px;"/></t-td>
  69. <t-td align="center" style="width: 50px !important;"><i class="fa fa-window-close" aria-hidden="true" @click="delRow(index)" style="font-size:20px;cursor: pointer;color: #999;margin-left:15px;" title="删除"></i></t-td>
  70. </t-tr>
  71. </t-table>
  72. </view>
  73. <view style="margin-bottom: 120px;">
  74. </view>
  75. <view class="uni-btn-v uni-column">
  76. <button type="primary" form-type="submit" style="border-radius: 15px;">编辑</button>
  77. </view>
  78. </uni-forms>
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. getSupplierNameAndType,GetEngineeringContracts
  84. } from "@/common/api/commonApi.js";
  85. import {
  86. Decimal
  87. } from 'decimal.js'; //decimal计算
  88. import {GetMaterials,UpdateMaterialIn,GetMaterialInByMaterialInCode,getContractAndSupplier,getGroupName,GetMaterialsForOut} from '@/common/api/MaterialInOut.js';
  89. import tTable from '@/components/t-table/t-table.vue';
  90. import tTh from '@/components/t-table/t-th.vue';
  91. import tTr from '@/components/t-table/t-tr.vue';
  92. import tTd from '@/components/t-table/t-td.vue';
  93. var sourceType = [
  94. ['camera'],
  95. ['album'],
  96. ['camera', 'album']
  97. ]
  98. var sizeType = [
  99. ['compressed'],
  100. ['original'],
  101. ['compressed', 'original']
  102. ]
  103. export default {
  104. components: {
  105. tTable,
  106. tTh,
  107. tTr,
  108. tTd
  109. },
  110. data() {
  111. return {
  112. intypeCode: '', //入库类型编码
  113. intypeName:'', //入库类型名
  114. inDate: this.$util.getDate({
  115. format: true
  116. }),
  117. contractName:'',
  118. contractCode:'',
  119. supplierName:'',
  120. contract:{}, //获取的材料合同集合数据
  121. userCode: this.$util.getState(this,"userCode"), //用户编号
  122. projectCode:this.$util.getState(this,"projectCode"),
  123. contractList: [], //合同
  124. materials:[], //材料
  125. outtypecode:'', //领料类型编码
  126. outtypeName:'', //领料类型名
  127. engineeringContractName:'', //工程合同名
  128. engineeringContractCode:'', //工程合同编码
  129. engineeringContract:{}, //工程合同数据集合
  130. engineeringMaterials:[], //工程材料
  131. engineeringError:'', //获取工程材料返回的错误信息
  132. materialOut:{}, //领料单主表数据
  133. title: 'choose/previewImage',
  134. imageList: [],
  135. sourceTypeIndex: 2,
  136. sourceType: ['拍照', '相册', '拍照或相册'],
  137. sizeTypeIndex: 2,
  138. sizeType: ['压缩', '原图', '压缩或原图'],
  139. countIndex: 5,
  140. count: [1, 2, 3, 4, 5],
  141. title1: 'picker',
  142. array: [],
  143. index: 0,
  144. date: this.$util.getDate({
  145. format: true
  146. }),
  147. startDate: this.$util.getDate('start'),
  148. endDate: this.$util.getDate('end'),
  149. control: true,
  150. columnNum: 3,
  151. imgList: [],
  152. urlList: [],
  153. maxCount: 5
  154. }
  155. },
  156. onLoad() {
  157. //console.info(page.path);
  158. console.info(uni.getStorageSync('storage_state'));
  159. //console.info(this);
  160. this.$util.persistLogin(this);
  161. //console.info(this.$store.state.user);
  162. },
  163. onUnload() {
  164. this.imageList = [],
  165. this.sourceTypeIndex = 2,
  166. this.sourceType = ['拍照', '相册', '拍照或相册'],
  167. this.sizeTypeIndex = 2,
  168. this.sizeType = ['压缩', '原图', '压缩或原图'],
  169. this.countIndex = 5;
  170. },
  171. created: function() {
  172. console.info('created');
  173. //console.info(this.intypeName);
  174. this.GetMaterialInByCode();
  175. },
  176. mounted:function(){
  177. console.info('mounted');
  178. //console.info('intype',this.intypeCode);
  179. },
  180. updated: function() {
  181. console.info('updated');
  182. console.info('contract',this.contract);
  183. //console.info('date',this.date);
  184. console.info(this);
  185. console.info('outtypeCode',this.outtypeCode);
  186. if(this.date){
  187. this.inDate=this.date;
  188. }
  189. if(this.contract){
  190. if(this.contract.length>0){
  191. this.getSupplierName(this.contract[0].supplierCode,this.contract[0].supplierTypeCode);
  192. }
  193. }
  194. },
  195. methods: {
  196. /**
  197. * 手动提交
  198. * @param {Object} form
  199. */
  200. submitForm(e) {
  201. console.info('submitForm');
  202. let _this = this;
  203. if(this.intypeCode==""){
  204. uni.showToast({
  205. title:'请选择入库类型',
  206. duration:3000,
  207. icon:'none'
  208. });
  209. return;
  210. }
  211. if(this.inDate==""){
  212. uni.showToast({
  213. title:'请选择入库日期',
  214. duration:3000,
  215. icon:'none'
  216. });
  217. return;
  218. }
  219. if(this.contractCode==""){
  220. uni.showToast({
  221. title:'请选择材料合同',
  222. duration:3000,
  223. icon:'none'
  224. });
  225. return;
  226. }
  227. if(!this.userCode){
  228. uni.showToast({
  229. title:'用户登录已失效,请重新登录',
  230. duration:3000,
  231. icon:'none'
  232. });
  233. return;
  234. }
  235. if(!this.contract){
  236. uni.showToast({
  237. title:'请重新选择材料合同',
  238. duration:3000,
  239. icon:'none'
  240. });
  241. return;
  242. }
  243. if (this.outtypeCode == "") {
  244. uni.showToast({
  245. title: '请选择领料类型',
  246. duration: 3000,
  247. icon: 'none'
  248. });
  249. return;
  250. }
  251. if (this.engineeringContractCode == "") {
  252. uni.showToast({
  253. title: '请选择工程合同',
  254. duration: 3000,
  255. icon: 'none'
  256. });
  257. return;
  258. }
  259. if (!this.engineeringMaterials) {
  260. uni.showToast({
  261. title: '请重新选择工程合同',
  262. duration: 3000,
  263. icon: 'none'
  264. });
  265. return;
  266. }
  267. if(this.engineeringError!=""){
  268. uni.showToast({
  269. title: _this.engineeringError,
  270. duration: 3000,
  271. icon: 'none'
  272. });
  273. return;
  274. }
  275. var materialIn = {
  276. materialInCode:_this.$util.getQuery("id"),
  277. materialInID:_this.$util.getQuery("id"),
  278. projectCode: this.$store.state.projectCode,
  279. groupCode: this.intypeCode,
  280. inDate:this.inDate,
  281. inPerson: this.userCode,
  282. inputPerson: this.userCode,
  283. contractCode: this.contractCode,
  284. supplierCode: this.contract[0].supplierCode,
  285. supplierTypeCode: this.contract[0].supplierTypeCode,
  286. supplierTypeId: this.contract[0].supplierTypeId
  287. };
  288. console.info("领料类型",this.outtypeCode);
  289. if(!this.outtypeCode){
  290. uni.showToast({
  291. title: '领料类型获取失败,请重新获取',
  292. duration: 3000,
  293. icon: 'none'
  294. });
  295. return;
  296. }
  297. //材料领料单主表
  298. var materialOut = {
  299. materialOutCode:_this.materialOut.materialOutCode,
  300. materialOutID:_this.materialOut.materialOutID,
  301. projectCode: _this.projectCode,
  302. groupCode: _this.outtypeCode,
  303. outDate: _this.inDate,
  304. outPerson: _this.userCode,
  305. inputPerson: _this.userCode,
  306. contractCode: _this.engineeringContractCode,
  307. doSupplierCode: _this.engineeringContract[0].supplierCode,
  308. supplierTypeCode: _this.engineeringContract[0].supplierTypeCode,
  309. supplierTypeId: _this.engineeringContract[0].supplierTypeId
  310. };
  311. console.info('materials',_this.materials);
  312. var list1 = this.materials;
  313. console.info('list1',list1);
  314. let list = [];
  315. let isLessThan=true;
  316. list1.forEach(function(item, index, array) {
  317. if(item.inQty<=0){
  318. console.info('入库数量不能小于0');
  319. isLessThan=false;
  320. return;
  321. }
  322. list.push({
  323. materialCode: item.materialCode,
  324. unit: item.unit,
  325. inQty: new Decimal(item.inQty).toFixed(2) - 0,
  326. inPrice: new Decimal(item.standardPrice).toFixed(2) - 0,
  327. noPassQty:new Decimal(item.noQty).toFixed(2) - 0,
  328. });
  329. //list.push({requisitionCode:'',contractCode:item.contractCode,estimateCash: 220});
  330. });
  331. if(!isLessThan){
  332. uni.showToast({
  333. title:'入库数量不能小于0',
  334. duration:3000,
  335. icon:'none'
  336. });
  337. return;
  338. }
  339. console.info("【list】",list);
  340. if (list.length <= 0) {
  341. uni.showToast({
  342. title: "请添加材料",
  343. icon: "none",
  344. duration: 3000
  345. });
  346. return;
  347. }
  348. let enginList=this.engineeringMaterials;
  349. if(enginList.length<=0){
  350. uni.showToast({
  351. title: '请重新选择工程合同',
  352. duration: 3000,
  353. icon: 'none'
  354. });
  355. return;
  356. }
  357. console.info("材料",list1);
  358. console.info('工程材料',enginList);
  359. if(list1.length!=enginList.length){
  360. uni.showToast({
  361. title: '添加的材料与工程合同中的材料不匹配',
  362. duration: 3000,
  363. icon: 'none'
  364. });
  365. return;
  366. }
  367. let clist1=[]; //添加的材料列表
  368. let mlist1=[]; //工程合同中材料列表
  369. list1.forEach(function(item,index,arr){
  370. clist1.push(item.materialCode);
  371. });
  372. enginList.forEach(function(item,index,arr){
  373. mlist1.push({materialCode:item.materialCode,materialName:item.materialName});
  374. });
  375. console.info('添加的材料列表',clist1);
  376. console.info('工程合同中材料列表',mlist1);
  377. let noMaterials=[];
  378. mlist1.forEach(function(item,index,arr){
  379. if(clist1.indexOf(item.materialCode)==-1){
  380. noMaterials.push(item.materialName);
  381. return;
  382. }
  383. });
  384. if(noMaterials.length>0){
  385. uni.showToast({
  386. title: noMaterials.join(),
  387. duration: 3000,
  388. icon: 'none'
  389. });
  390. return;
  391. }
  392. //return;
  393. var data = {
  394. materialIn: materialIn,
  395. materialOut:materialOut,
  396. mDetailList: list
  397. };
  398. console.info('data',data);
  399. //return;
  400. //var strList=JSON.stringify(list);
  401. //var strData=JSON.stringify(data);
  402. UpdateMaterialIn(data).then((res) => {
  403. console.info("submitform应答返回值",res);
  404. if(res=="-1"){
  405. uni.showToast({
  406. title: '修改项不存在',
  407. icon: 'none',
  408. duration: 3000
  409. });
  410. return;
  411. }
  412. else if(res=="-2"){
  413. uni.showToast({
  414. title: '非待审核状态,不能修改',
  415. icon: 'none',
  416. duration: 3000
  417. });
  418. return;
  419. }
  420. if (res) {
  421. //上传图片
  422. _this.uploadFileToServe(res);
  423. uni.navigateTo({
  424. url: '/pages/template/GetMaterialIns/GetMaterialIns'
  425. })
  426. } else {
  427. uni.showToast({
  428. title: '修改失败,重新操作',
  429. icon: 'none',
  430. duration: 3000
  431. })
  432. }
  433. });
  434. },
  435. bindPickerChange: function(e) {
  436. //console.log('picker发送选择改变,携带值为:' + e.detail.value);
  437. //console.info(e.detail);
  438. this.index = e.detail.value;
  439. this.changeType = this.array[this.index];
  440. console.info(this.changeType);
  441. },
  442. bindDateChange: function(e) {
  443. this.date = e.detail.value;
  444. this.requisitionDate = this.date;
  445. console.info(this.date);
  446. },
  447. GetDropDown: function() {
  448. let that = this;
  449. GetQianzhengDropDown().then((res) => {
  450. console.info(res);
  451. res.forEach(function(item, index, array) {
  452. that.$set(that.array, index, item);
  453. });
  454. that.changeType = that.array[0];
  455. });
  456. },
  457. openWindow: function() {
  458. let _this = this;
  459. //console.info('监听事件外部this');
  460. //console.info(this);
  461. _this.saveTemp(_this);
  462. if(_this.contractCode==undefined||_this.contractCode==''){
  463. uni.showToast({
  464. title:'请选择材料合同',
  465. icon:'none',
  466. duration:3000
  467. });
  468. return;
  469. }
  470. //创建名字为fire的监听器,监听子页面传值事件
  471. uni.$on('materials', function(data) {
  472. console.info("监听materials子页面的传值",data);
  473. //从子页面返回父页面,原来表单已经填写的值会丢失,因此需要重新赋值
  474. _this.getTemp(_this);
  475. _this.materials = [];
  476. data.forEach(function(item, index, array) {
  477. //console.info("foreach");
  478. _this.$set(_this.materials, index, item);
  479. });
  480. //接收一次监听,一旦监听到回传值,则清除监听事件,若不清除,会占用资源
  481. uni.$off("materials");
  482. console.info("监听materials子页面的传值结束");
  483. });
  484. //打开子页面
  485. uni.navigateTo({
  486. url: "/pages/template/selectmaterials/selectmaterials?contractCode="+_this.contractCode
  487. })
  488. },
  489. delRow: function(index) {
  490. console.info("删除");
  491. console.info(this.materials[index]);
  492. this.materials.splice(index, 1);
  493. },
  494. /*
  495. 上传后返回的值:
  496. list:上传后图片数组
  497. v:返回当前上传图片的临时路径
  498. */
  499. chooseFile(list, v) {
  500. console.log("上传图片_list:", list)
  501. console.log("上传图片_v:", v);
  502. this.urlList = list;
  503. console.info("urlList", this.urlList);
  504. },
  505. /*
  506. 删除图片:
  507. list:删除返回删除后剩余的图片数组
  508. eq:返回删除的数组
  509. */
  510. imgDelete(list, eq) {
  511. console.log("删除图片_list:", list);
  512. console.log("删除图片_eq:", eq);
  513. this.urlList = list;
  514. console.info("urlList", this.urlList);
  515. },
  516. /*
  517. 执行上传服务:
  518. urlList:要上传的图片:数组类型
  519. */
  520. uploadFileToServe(masterCode) {
  521. let _this = this;
  522. var urlList = _this.urlList;
  523. if (!urlList || urlList.length <= 0) {
  524. return;
  525. };
  526. //console.info(urlList);
  527. //return;
  528. for (let i = 0; i < urlList.length; i++) {
  529. uni.uploadFile({
  530. url: '/api/Common/UploadImage',
  531. filePath: urlList[i],
  532. name: 'file',
  533. formData: {
  534. createPerson: _this.$util.getState(_this,'userCode'),
  535. masterCode: masterCode,
  536. attachMentType:'MaterialIn'
  537. },
  538. headers: {
  539. 'Content-Type': 'multipart/form-data; boundary = ' + new Date().getTime()
  540. //这里要把content-type设置为multipard/form-data,同时还要设置boundary
  541. },
  542. success: (uploadFileRes) => {
  543. console.log("附件上传:", uploadFileRes.data);
  544. }
  545. });
  546. }
  547. },
  548. /*
  549. 获取入库类型
  550. */
  551. getType() {
  552. let _this = this;
  553. console.info('gettype',_this);
  554. _this.saveTemp(_this);
  555. //创建名字为fire的监听器,监听子页面传值事件
  556. uni.$on('intype', function(data) {
  557. console.info("监听intype子页面的传值", data);
  558. console.info('监听',_this);
  559. _this.getTemp(_this);
  560. _this.intypeCode=data[0].id;
  561. _this.intypeName=data[0].name;
  562. _this.$nextTick(function(){
  563. //更新dom
  564. });
  565. console.info(data[0].id,data[0].name);
  566. console.info(_this.intypeCode,_this.intypeName);
  567. //接收一次监听,一旦监听到回传值,则清除监听事件,若不清除,会占用资源
  568. uni.$off("intype");
  569. });
  570. uni.navigateTo({
  571. url: '/pages/tree/tree?classCode=1503'
  572. });
  573. },
  574. /*
  575. 获取领料类型
  576. */
  577. getOutType() {
  578. let _this = this;
  579. console.info('gettype',_this);
  580. _this.saveTemp(_this);
  581. //创建名字为fire的监听器,监听子页面传值事件
  582. uni.$on('outtype', function(data) {
  583. console.info("监听outtype子页面的传值", data);
  584. console.info('监听',_this);
  585. _this.getTemp(_this);
  586. _this.outtypeCode=data[0].id;
  587. _this.outtypeName=data[0].name;
  588. _this.$nextTick(function(){
  589. //更新dom
  590. });
  591. console.info(data[0].id,data[0].name);
  592. console.info(_this.outtypeCode,_this.outtypeName);
  593. //接收一次监听,一旦监听到回传值,则清除监听事件,若不清除,会占用资源
  594. uni.$off("outtype");
  595. });
  596. uni.navigateTo({
  597. url: '/pages/treeout/treeout?classCode=1505'
  598. });
  599. },
  600. /*获取材料合同*/
  601. getContract(projectCode){
  602. console.info('getContract',projectCode);
  603. let _this = this;
  604. _this.saveTemp(_this); //表单存入缓存
  605. //创建名字为fire的监听器,监听子页面传值事件
  606. uni.$on('contract', function(data) {
  607. console.info("监听contract子页面的传值", data);
  608. _this.getTemp(_this); //自缓存中取出表单数据,重新赋值
  609. _this.contractCode=data[0].contractCode;
  610. _this.contractName=data[0].contractName;
  611. _this.contract=data;
  612. console.info('_this.contract',_this.contract);
  613. //接收一次监听,一旦监听到回传值,则清除监听事件,若不清除,会占用资源
  614. uni.$off("contract");
  615. });
  616. uni.navigateTo({
  617. url: '/pages/template/SelectContract/SelectContract?projectCode='+projectCode
  618. });
  619. },
  620. /*获取工程合同*/
  621. getEngineeringContract(projectCode){
  622. console.info('getEngineeringContract',projectCode);
  623. let _this = this;
  624. _this.saveTemp(_this); //表单存入缓存
  625. //创建名字为fire的监听器,监听子页面传值事件
  626. uni.$on('engineeringContract', function(data) {
  627. console.info("监听工程合同子页面开始");
  628. console.info("监听engineeringContract子页面的传值", data);
  629. _this.getTemp(_this); //自缓存中取出表单数据,重新赋值
  630. _this.engineeringContractCode=data[0].contractCode;
  631. _this.engineeringContractName=data[0].contractName;
  632. _this.engineeringContract=data;
  633. console.info('engineeringContract',_this.engineeringContract);
  634. //获取工程材料列表
  635. GetMaterialsForOut(_this.$util.getState(_this,'projectCode'),data[0].contractCode).then(res=>{
  636. if(typeof res=='string'){
  637. _this.engineeringError=res;
  638. console.info('engineeringError',_this.engineeringError);
  639. return;
  640. }
  641. if(res.length>0){
  642. res.forEach(function(item,index,arr){
  643. //给工程材料集合赋值
  644. _this.$set(_this.engineeringMaterials, index, item);
  645. });
  646. console.info('engineeringMaterials',_this.engineeringMaterials);
  647. }
  648. });
  649. console.info("监听工程合同子页面结束");
  650. //接收一次监听,一旦监听到回传值,则清除监听事件,若不清除,会占用资源
  651. uni.$off("engineeringContract");
  652. });
  653. uni.navigateTo({
  654. url: '/pages/template/SelectEgineeringContract/SelectEgineeringContract?projectCode='+projectCode
  655. });
  656. },
  657. /* 获取供应商名称 */
  658. getSupplierName(supplierCode, supplierTypeCode){
  659. console.info('getSupplierName');
  660. console.info('supplierCode',supplierCode);
  661. console.info('supplierTypeCode',supplierTypeCode);
  662. let that=this;
  663. if(supplierCode&&supplierTypeCode){
  664. getSupplierNameAndType(supplierCode, supplierTypeCode).then(res=>{
  665. console.info('getSupplierNameAndType',res);
  666. that.supplierName=res;
  667. });
  668. }
  669. },
  670. saveTemp(_this){ //临时存
  671. uni.setStorage({
  672. key:'intypeName',
  673. data:_this.intypeName
  674. });
  675. uni.setStorage({
  676. key:'intypeCode',
  677. data:_this.intypeCode
  678. });
  679. uni.setStorage({
  680. key:'inDate',
  681. data:_this.inDate
  682. });
  683. uni.setStorage({
  684. key:'contractCode',
  685. data:_this.contractCode
  686. });
  687. uni.setStorage({
  688. key:'contractName',
  689. data:_this.contractName
  690. });
  691. uni.setStorage({
  692. key:'supplierCode',
  693. data:_this.supplierCode
  694. });
  695. uni.setStorage({
  696. key:'supplierName',
  697. data:_this.supplierName
  698. });
  699. uni.setStorage({
  700. key:'contract',
  701. data:_this.contract
  702. });
  703. uni.setStorage({
  704. key:'usercode',
  705. data:_this.usercode
  706. });
  707. uni.setStorage({
  708. key:'imageList',
  709. data:_this.imageList
  710. });
  711. uni.setStorage({
  712. key:'engineeringContractCode',
  713. data:_this.engineeringContractCode
  714. });
  715. uni.setStorage({
  716. key:'engineeringContractName',
  717. data:_this.engineeringContractName
  718. });
  719. uni.setStorage({
  720. key:'engineeringError',
  721. data:_this.engineeringError
  722. });
  723. uni.setStorage({
  724. key:'engineeringMaterials',
  725. data:_this.engineeringMaterials
  726. });
  727. uni.setStorage({
  728. key:'outtypeName',
  729. data:_this.outtypeName
  730. });
  731. uni.setStorage({
  732. key:'outtypeCode',
  733. data:_this.outtypeCode
  734. });
  735. },
  736. getTemp(_this){ //获取缓存,重新给表单赋值
  737. _this.intypeCode=uni.getStorageSync('intypeCode');
  738. _this.intypeName=uni.getStorageSync('intypeName');
  739. _this.inDate=uni.getStorageSync('inDate');
  740. _this.contractCode=uni.getStorageSync('contractCode');
  741. _this.contractName=uni.getStorageSync('contractName');
  742. _this.supplierCode=uni.getStorageSync('supplierCode');
  743. _this.supplierName=uni.getStorageSync('supplierName');
  744. _this.supplierCode=uni.getStorageSync('supplierCode');
  745. _this.usercode=uni.getStorageSync('usercode');
  746. _this.contract=uni.getStorageSync('contract');
  747. _this.engineeringContractCode=uni.getStorageSync('engineeringContractCode');
  748. _this.engineeringContractName=uni.getStorageSync('engineeringContractName');
  749. _this.engineeringError=uni.getStorageSync('engineeringError');
  750. _this.engineeringMaterials=uni.getStorageSync('engineeringMaterials');
  751. _this.outtypeCode=uni.getStorageSync('outtypeCode');
  752. _this.outtypeName=uni.getStorageSync('outtypeName');
  753. },
  754. GetMaterialInByCode(){
  755. console.info("GetMaterialInByCode",this);
  756. let _this=this;
  757. let id=this.$util.getQuery("id");
  758. GetMaterialInByMaterialInCode(id).then(res=>{
  759. console.info('GetMaterialInByMaterialInCode',res);
  760. let mainEntity=res.mainEntity;
  761. let materialOut=res.materialOut;
  762. let subList=res.subList;
  763. _this.materialOut=materialOut;
  764. console.info('projectCode',_this.projectCode);
  765. if(mainEntity.projectCode!=_this.projectCode){
  766. uni.showModal({
  767. title: '提示',
  768. content: '非本人,无编辑权限',
  769. success: function (res) {
  770. if (res.confirm||res.cancel) {
  771. uni.navigateTo({
  772. url:'../GetMaterialIns/GetMaterialIns'
  773. })
  774. }
  775. }
  776. });
  777. }
  778. //初始化赋值
  779. _this.intypeCode=mainEntity.groupCode;
  780. _this.date=mainEntity.inDate.substring(0,10);
  781. _this.contractCode=mainEntity.contractCode;
  782. getContractAndSupplier(mainEntity.contractCode).then(res=>{
  783. console.info('getContractAndSupplier',res);
  784. _this.contractCode=res[0].contractCode;
  785. _this.contractName=res[0].contractName;
  786. console.info('res.contractName',res[0].contractName);
  787. console.info('_this.contractName',_this.contractName);
  788. _this.contract=res;
  789. });
  790. getGroupName(mainEntity.groupCode).then(res=>{
  791. console.info('getGroupName',res);
  792. _this.intypeName=res;
  793. });
  794. //领料类型获取
  795. _this.outtypeCode=materialOut.groupCode;
  796. console.info("_this.outtypecode",_this.outtypeCode);
  797. getGroupName(materialOut.groupCode).then(res=>{
  798. console.info('getGroupName',res);
  799. _this.outtypeName=res;
  800. });
  801. //工程合同
  802. _this.engineeringContractCode=materialOut.contractCode;
  803. getContractAndSupplier(materialOut.contractCode).then(res=>{
  804. console.info('工程合同',res);
  805. _this.engineeringContractName=res[0].contractName;
  806. console.info('res.engineeringContractName',res[0].contractName);
  807. _this.engineeringContract=res;
  808. //获取工程材料列表
  809. GetMaterialsForOut(_this.$util.getState(_this,'projectCode'),materialOut.contractCode).then(res=>{
  810. if(typeof res=='string'){
  811. _this.engineeringError=res;
  812. console.info('engineeringError',_this.engineeringError);
  813. return;
  814. }
  815. if(res.length>0){
  816. res.forEach(function(item,index,arr){
  817. //给工程材料集合赋值
  818. _this.$set(_this.engineeringMaterials, index, item);
  819. });
  820. console.info('engineeringMaterials',_this.engineeringMaterials);
  821. }
  822. });
  823. });
  824. subList.forEach(function(item, index, array) {
  825. //console.info("foreach");
  826. _this.$set(_this.materials, index, item);
  827. });
  828. });
  829. },
  830. }
  831. }
  832. </script>
  833. <style scoped>
  834. /* 头条小程序组件内不能引入字体 */
  835. /* #ifdef MP-TOUTIAO */
  836. @font-face {
  837. font-family: uniicons;
  838. font-weight: normal;
  839. font-style: normal;
  840. src: url("~@/static/uni.ttf") format("truetype");
  841. }
  842. /* #endif */
  843. page {
  844. display: flex;
  845. flex-direction: column;
  846. box-sizing: border-box;
  847. background-color: #efeff4;
  848. min-height: 100%;
  849. height: auto;
  850. }
  851. view {
  852. font-size: 14px;
  853. line-height: inherit;
  854. }
  855. .uni-form-item__title {
  856. font-size: 16px;
  857. line-height: 24px;
  858. }
  859. .uni-input-wrapper {
  860. /* #ifndef APP-NVUE */
  861. display: flex;
  862. /* #endif */
  863. padding: 8px 13px;
  864. flex-direction: row;
  865. flex-wrap: nowrap;
  866. background-color: #FFFFFF;
  867. }
  868. .title {
  869. background-color: #efefef;
  870. padding: 5px 20px;
  871. }
  872. .uni-input {
  873. height: 28px;
  874. line-height: 28px;
  875. font-size: 15px;
  876. padding: 5px;
  877. flex: 1;
  878. background-color: #FFFFFF;
  879. }
  880. .uni-input-small {
  881. height: 28px;
  882. line-height: 28px;
  883. font-size: 15px;
  884. padding: 5px;
  885. flex: 1;
  886. width: 270px;
  887. background-color: #FFFFFF;
  888. }
  889. .uni-icon {
  890. height: 28px;
  891. line-height: 28px;
  892. font-size: 20px;
  893. padding-right: 15px;
  894. color: #5555ff;
  895. width: 50px;
  896. }
  897. .uni-eye-active {
  898. color: #007AFF;
  899. }
  900. .uni-btn-v {
  901. position: fixed;
  902. bottom: 0;
  903. width: 100%;
  904. }
  905. .header-slot-box {
  906. font-size: 15px;
  907. margin: 5px 5px;
  908. width: 20%;
  909. justify-content: center;
  910. }
  911. .body-slot-box {
  912. font-size: 15px;
  913. margin: 5px 5px;
  914. width: 40%;
  915. justify-content: center;
  916. }
  917. .footer-slot-box {
  918. font-size: 15px;
  919. margin: 5px 5px;
  920. width: 40%;
  921. justify-content: center;
  922. }
  923. .uni-textarea textarea {
  924. font-size: 15px;
  925. }
  926. .content {
  927. padding: 40rpx;
  928. background-color: #fff;
  929. }
  930. /* 上传控件 */
  931. .uploadControl {
  932. border: 1rpx solid #eee;
  933. border-radius: 10rpx;
  934. width: 130rpx;
  935. display: block;
  936. height: 130rpx;
  937. text-align: center;
  938. line-height: 130rpx;
  939. font-size: 30rpx;
  940. color: #888;
  941. background-color: #eeeeee;
  942. }
  943. .bg1 {
  944. background-color: #EFEFEF;
  945. }
  946. </style>