MaterialInAdd.vue 25 KB

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