index.vue 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356
  1. <template>
  2. <view class="app-container">
  3. <uni-nav-bar dark :fixed="true" shadow background-color="#007AFF" status-bar :title="formData.billTypeName"
  4. left-icon="left" left-text="返回" @clickLeft="handleBack"
  5. right-icon="refreshempty" @clickRight="SendNumEmpty"/>
  6. <view class="scan-header">
  7. <uni-forms-item name="remark" label="条码" :label-width="lableWidth" labelAlign="right"
  8. style="margin-bottom: 0px; padding: 0px 15px 0px 15px;" >
  9. <uni-easyinput type="text" :inputBorder="true" v-model="barCode"
  10. :clearable="false" @confirm="scanSearch" ></uni-easyinput>
  11. <view class="icon" @click="handleScanClick">
  12. <uni-icons type="scan" size="20"></uni-icons>
  13. </view>
  14. </uni-forms-item>
  15. </view>
  16. <view class="cpck-content">
  17. <scroll-view :scroll-top="scrollTop" :show-scrollbar="true" scroll-y="true" class="scroll-Y">
  18. <view class="form-container">
  19. <uni-forms
  20. :rules="rules"
  21. :value="formData"
  22. ref="form"
  23. validate-trigger="submit"
  24. err-show-type="toast"
  25. >
  26. <uni-forms-item name="billTypeCode" label="单据类型" :label-width="lableWidth" labelAlign="right">
  27. <uni-data-select
  28. v-model="formData.billTypeCode"
  29. :localdata="billTypeOption"
  30. @change="ywlxChange"
  31. ></uni-data-select>
  32. </uni-forms-item>
  33. <uni-forms-item name="warehouseCode" :required="rulesStar('warehouseCode')" v-if="fieldHidden('warehouseCode')" label="仓库" :label-width="lableWidth" labelAlign="right">
  34. <uni-easyinput type="text" v-model="formData.warehouseCode" v-show="false"></uni-easyinput>
  35. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  36. v-model="formData.warehouseName" suffixIcon="compose" @iconClick="setScan('WH')"></uni-easyinput>
  37. </uni-forms-item>
  38. <uni-forms-item name="backTaskOutsCode" :required="rulesStar('backTaskOutsCode')" v-if="fieldHidden('backTaskOutsCode')" label="任务编码" :label-width="lableWidth" labelAlign="right">
  39. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  40. v-model="formData.backTaskOutsCode" suffixIcon="search" @iconClick="searchIconClick('task')"></uni-easyinput>
  41. </uni-forms-item>
  42. <uni-forms-item name="deptCode" :required="rulesStar('deptCode')" v-if="fieldHidden('deptCode')" label="部门" :label-width="lableWidth" labelAlign="right">
  43. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true" v-show="false"
  44. v-model="formData.deptCode" ></uni-easyinput>
  45. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  46. v-model="formData.deptName" suffixIcon="search" @iconClick="searchIconClick('dept')"></uni-easyinput>
  47. </uni-forms-item>
  48. <uni-forms-item name="employeeCode" :required="rulesStar('employeeCode')" v-if="fieldHidden('employeeCode')" label="职员" :label-width="lableWidth" labelAlign="right">
  49. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  50. v-model="formData.employeeCode" v-show="false" ></uni-easyinput>
  51. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  52. v-model="formData.employeeName" suffixIcon="search" @iconClick="searchIconClick('empl')"></uni-easyinput>
  53. </uni-forms-item>
  54. <uni-forms-item name="customerCode" :required="rulesStar('customerCode')" v-if="fieldHidden('customerCode')" label="客户" :label-width="lableWidth" labelAlign="right">
  55. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true" v-show="false"
  56. v-model="formData.customerCode" ></uni-easyinput>
  57. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  58. v-model="formData.customerName" suffixIcon="search" @iconClick="searchIconClick('cust')"></uni-easyinput>
  59. </uni-forms-item>
  60. <uni-forms-item name="supplierCode" :required="rulesStar('supplierCode')" v-if="fieldHidden('supplierCode')" label="供应商" :label-width="lableWidth" labelAlign="right">
  61. <uni-easyinput type="text" :inputBorder="true" v-model="formData.supplierCode" v-show="false" :disabled="true"></uni-easyinput>
  62. <uni-easyinput type="text" :inputBorder="true"
  63. v-model="formData.supplierName" :disabled="true" :styles="styleInput"
  64. :suffixIcon="formData.backTaskOutsCode!=''? '' : 'search'" @iconClick="searchIconClick('supp')"></uni-easyinput>
  65. </uni-forms-item>
  66. <uni-forms-item name="extendCode01" :required="rulesStar('extendCode01')" v-if="fieldHidden('extendCode01')" label="收发类别" :label-width="lableWidth" labelAlign="right">
  67. <uni-easyinput type="text" :disabled="true" :inputBorder="true" v-show="false"
  68. v-model="formData.extendCode01" ></uni-easyinput>
  69. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  70. v-model="formData.extendName01" suffixIcon="search" @iconClick="searchIconClick('ext01')"></uni-easyinput>
  71. </uni-forms-item>
  72. <uni-forms-item name="locationCode" :required="rulesStar('locationCode')" v-if="fieldHidden('locationCode')" label="货位" :label-width="lableWidth" labelAlign="right">
  73. <uni-easyinput type="text" v-model="formData.locationCode" v-show="false"></uni-easyinput>
  74. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  75. v-model="formData.locationName" suffixIcon="compose" @iconClick="setScan('PT')"></uni-easyinput>
  76. </uni-forms-item>
  77. <uni-forms-item name="palletCode" :required="rulesStar('palletCode')" v-if="fieldHidden('palletCode')" label="托盘" :label-width="lableWidth" labelAlign="right">
  78. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  79. v-model="formData.palletCode" suffixIcon="search" @iconClick="searchIconClick('pall')"></uni-easyinput>
  80. </uni-forms-item>
  81. <uni-forms-item name="packageCode" :required="rulesStar('packageCode')" v-if="fieldHidden('packageCode')" label="包装" :label-width="lableWidth" labelAlign="right">
  82. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  83. v-model="formData.packageCode" suffixIcon="search" @iconClick="searchIconClick('pack')"></uni-easyinput>
  84. </uni-forms-item>
  85. <uni-forms-item name="labelCode" :required="rulesStar('labelCode')" v-if="fieldHidden('labelCode')" label="标签编码" :label-width="lableWidth" labelAlign="right">
  86. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  87. v-model="formData.labelCode" suffixIcon="compose" @iconClick="setScan('L')"></uni-easyinput>
  88. </uni-forms-item>
  89. <uni-forms-item name="materialCode" :required="rulesStar('materialCode')" v-if="fieldHidden('materialCode')" label="物料" :label-width="lableWidth" labelAlign="right">
  90. <uni-easyinput type="text" v-model="formData.materialCode" v-show="false" ></uni-easyinput>
  91. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true"
  92. v-model="formData.materialName"></uni-easyinput>
  93. </uni-forms-item>
  94. <uni-forms-item name="batch" :required="rulesStar('batch')" v-if="fieldHidden('batch')" label="批号" :label-width="lableWidth" labelAlign="right">
  95. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true" v-model="formData.batch"></uni-easyinput>
  96. </uni-forms-item>
  97. <uni-forms-item name="unitCode" :required="rulesStar('unitCode')" v-if="fieldHidden('unitCode')" label="单位" :label-width="lableWidth" labelAlign="right">
  98. <uni-easyinput type="text" v-model="formData.unitCode" v-show="false"></uni-easyinput>
  99. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true" v-model="formData.unitName"></uni-easyinput>
  100. </uni-forms-item>
  101. <uni-forms-item name="stockQty" :required="rulesStar('stockQty')" v-if="fieldHidden('stockQty')" label="标签数量" :label-width="lableWidth" labelAlign="right">
  102. <uni-easyinput type="number" :inputBorder="true"
  103. v-model="formData.stockQty" @input="bqslInputHandle" ></uni-easyinput>
  104. </uni-forms-item>
  105. <uni-forms-item name="rwQty" :required="rulesStar('rwQty')" v-if="fieldHidden('rwQty')" label="任务数量" :label-width="lableWidth" labelAlign="right">
  106. <uni-easyinput type="text" :disabled="true" :styles="styleInput" :inputBorder="true" v-model="formData.rwQty"></uni-easyinput>
  107. </uni-forms-item>
  108. </uni-forms>
  109. </view>
  110. </scroll-view>
  111. </view>
  112. <view class="page-bottom">
  113. <view class="p-b-btn">
  114. <uni-badge class="uni-badge-left-margin" :text="mxNum" :max-num="999" absolute="rightTop" :offset="[-3, -3]" size="small">
  115. <view class="box"><text class="box-text" @click="handleMx">明细</text></view>
  116. </uni-badge>
  117. </view>
  118. <view class="p-b-btn" @click="$noMultipleClicks(handleSave)">
  119. <text class="box-text" v-show="isShowSaveButton">暂存</text>
  120. </view>
  121. <view class="p-b-btn" @click="handleAuto">
  122. <text class="box-text">{{autoButtonTitle}}</text>
  123. </view>
  124. <view class="p-b-btn" @click="handleBack">
  125. <text class="box-text">返回</text>
  126. </view>
  127. </view>
  128. <scan-code />
  129. <!-- 明细弹窗 -->
  130. <MxPopup ref="mxPopup" @sendNum="getSendNum" :formData="formData" @sendData="getSendData"/>
  131. <!-- 任务清单弹窗 -->
  132. <RwbmPopup ref="rwbmPopup" :title="rwbmTitle" :idxFlag="rwbmFlag" :formData="formData" @sendData="getSendData" />
  133. <!-- 部门弹窗 -->
  134. <BmPopup ref="bmPopup" :title="bmTitle" :idxFlag="bmFlag" :formData="formData" @sendData="getSendData"/>
  135. <!-- 职员 -->
  136. <ZyPopup ref="zyPopup" :title="zyTitle" :idxFlag="zyFlag" :formData="formData" @sendData="getSendData"/>
  137. <!-- 客户 -->
  138. <KhPopup ref="khPopup" :title="khTitle" :idxFlag="khFlag" :formData="formData" @sendData="getSendData"/>
  139. <!-- 收发类别 -->
  140. <SflbPopup ref="sflbPopup" :title="sflbTitle" :idxFlag="sflbFlag" :formData="formData" @sendData="getSendData"/>
  141. <!-- 供应商 -->
  142. <GysPopup ref="gysPopup" :title="gysTitle" :idxFlag="gysFlag" :formData="formData" @sendData="getSendData"/>
  143. <!-- 托盘 -->
  144. <TpPopup ref="tpPopup" :title="tpTitle" :idxFlag="tpFlag" :formData="formData" @sendData="getSendData"/>
  145. <!-- 包装 -->
  146. <BzPopup ref="bzPopup" :title="bzTitle" :idxFlag="bzFlag" :formData="formData" @sendData="getSendData"/>
  147. </view>
  148. </template>
  149. <script>
  150. import scanCode from "@/components/scan/scan.vue";
  151. import { getDicts } from "@/api/system/dict/data"; // 字典
  152. import RwbmPopup from './popup/commonpopup.vue' // 任务编码
  153. import BmPopup from './popup/commonpopup.vue' // 部门
  154. import ZyPopup from './popup/commonpopup.vue' // 职员
  155. import KhPopup from './popup/commonpopup.vue' // 客户
  156. import SflbPopup from './popup/commonpopup.vue' // 收发类别
  157. import GysPopup from './popup/commonpopup.vue' // 供应商
  158. import TpPopup from './popup/commonpopup.vue' // 托盘
  159. import BzPopup from './popup/commonpopup.vue' // 包装
  160. import MxPopup from './popup/mxPopup.vue'
  161. import {addStockOut, listWarehouse, listLocation, listBackStockTaskOut, listBackStockOut, listPallet, listPackage,listExtend, getListFieldSetting, queryBillTypeCache } from '@/api/wms/backStockOut.js'
  162. import { listFieldDefault } from '@/api/wms/report.js'
  163. import storage from '@/utils/storage'
  164. import { nanoid } from 'nanoid'; //唯一值 nanoid
  165. export default {
  166. components: {
  167. scanCode,
  168. RwbmPopup,
  169. BmPopup,
  170. MxPopup,
  171. ZyPopup,
  172. KhPopup,
  173. SflbPopup,
  174. GysPopup,
  175. TpPopup,
  176. BzPopup
  177. },
  178. props: {},
  179. async onLoad(option) {
  180. //下面请求如果失败改为false
  181. let isRequest = true;
  182. //字段设置
  183. try {
  184. const res = await this.retryRequest(getListFieldSetting, { billCode: "backStockOut" });
  185. // 处理响应数据
  186. this.fieldSetting = res.rows;
  187. } catch (error) {
  188. isRequest = false;
  189. }
  190. //单据类型
  191. try {
  192. const res = await this.retryRequest(queryBillTypeCache, {billCode: "backStockOut"});
  193. // 处理响应数据
  194. let tmpData = res.rows;
  195. this.billTypeOption = tmpData.filter(item => item.isEnableApp == 0 && item.status == 0)
  196. .map(item => ({
  197. billTypeCode: item.billTypeCode,
  198. billTypeName: item.billTypeName,
  199. value: item.billTypeCode,
  200. text: item.billTypeName,
  201. taskValue: item.taskBillTypeCode ? "'" + item.taskBillTypeCode.replace(/,/g, "','") + "'" : '',
  202. isControlTask: item.backTaskBillTypeCode ? item.isControlTask : 0,
  203. }));
  204. //触发单据类型变更
  205. this.ywlxChange(option.ywlx);
  206. } catch (error) {
  207. isRequest = false;
  208. }
  209. if(isRequest==false){
  210. uni.showModal({
  211. title: '获取单据信息失败',
  212. content: '请返回菜单重新进入',
  213. showCancel: false ,//不显示取消按钮
  214. success: function (res) {
  215. if (res.confirm) {
  216. uni.navigateBack();
  217. }
  218. }
  219. })
  220. }else{
  221. this.isRequest=true
  222. }
  223. },
  224. onUnload(){
  225. uni.removeStorageSync('stock_key');
  226. },
  227. onBackPress(options) {
  228. if (options.from === 'navigateBack') {
  229. // 来自于导航条返回按钮或者系统返回按钮的事件
  230. return false;
  231. }
  232. // 双击返回的逻辑
  233. const now = Date.now();
  234. if (this.lastBackPress && now - this.lastBackPress < 1000) {
  235. // 如果两次点击的间隔小于1000毫秒,则可以认为是双击
  236. //这时退出
  237. return false;
  238. } else {
  239. this.lastBackPress = now;
  240. uni.showToast({
  241. title: '再按一次退出',
  242. icon: 'none'
  243. });
  244. setTimeout(() => {
  245. this.lastBackPress = null;
  246. }, 1000);
  247. return true;
  248. }
  249. },
  250. data() {
  251. return {
  252. isRequest: false, //onLoad请求成功时改为true,否则不允许保存
  253. remarkFocus: false,
  254. mxNum: 0, //明细按钮数量
  255. suppShow: true, // 是否显示供应商
  256. isShowSaveButton: false, //是否显示保存按钮
  257. currentSelectBillTypeCode: '', // 当前单据类型
  258. // 必填项
  259. ext1Star: false, //收发类别是否是必填项
  260. emplStar: false, //职员是否是必填项
  261. autoButtonTitle: '自动',
  262. scrollTop: 0,
  263. old: {
  264. scrollTop: 0
  265. },
  266. billTypeOption: [], // 业务类型字典选择框数据
  267. barCode: '', //条码
  268. formData: {
  269. // 单据类型
  270. billTypeCode: "", // 单据类型
  271. billTypeName: "",// 单据类型的名称(显示使用)
  272. taskBillTypeCode: "", //单据类型对应的任务类型
  273. isControlTask: null, //任务用,是否可超量
  274. // 任务编码
  275. backTaskOutsCode: "",// 出库任务退编码|行号
  276. taskOutsId: "",// 出库任务子表id
  277. backTaskOutsId: "",// 出库任务退子表id
  278. // 部门
  279. deptCode: "", //部门
  280. deptName: "", //部门名称
  281. // 职员
  282. employeeCode: "", // 职员
  283. employeeName: "", // 职员名称
  284. //客户
  285. customerCode: "", //客户编码
  286. customerName: "", //客户名称
  287. // 供应商
  288. supplierCode : "", //供应商
  289. supplierName: "", //供应商名称
  290. // 收发类别
  291. extendName01: "", // 收发类别
  292. extendCode01: "", // 收发类别编码
  293. // 仓库
  294. warehouseCode: "", // 仓库
  295. warehouseName: "", // 仓库名称
  296. isSupplement: "", //是否补料
  297. //预留
  298. extendCode02: "",
  299. extendCode03: "",
  300. extendCode04: "",
  301. extendCode05: "",
  302. // 组id
  303. appGroupId: "",
  304. // ===== 以下 保存时转化为 wmsBackStockOutsList=====
  305. //任务子表id
  306. taskOutsId: "",
  307. // 货位
  308. locationCode: "", // 货位编码
  309. locationName: "", // 货位名称
  310. // 标签
  311. labelCode: "", // 标签编码
  312. // 物料
  313. materialCode: "", // 物料编码
  314. materialName: "", //物料名称
  315. isSupplement: 1, //是否补料
  316. // 批号
  317. batch: "", //批号
  318. // 托盘
  319. palletCode: "", // 托盘编码
  320. palletName: "", // 托盘名称
  321. // 包装
  322. packageCode: "", // 包装编码
  323. packageName: "", // 包装名称
  324. //单位
  325. unitCode: "", //单位编码
  326. unitName: "", //单位名称
  327. stockQty: "", // 标签数量
  328. rwQty: "",// 任务数量
  329. batch1: "", //批号1
  330. batch2: "", //批号2
  331. materialSpecification: "", //物料规格
  332. isLocation:"",
  333. isPackage:"",
  334. isPallet:"",
  335. },
  336. show: false,
  337. lableWidth: '80px',
  338. styleInput: {
  339. color: '#333',
  340. backgroundColor: '#fff',
  341. disableColor: '#fff',
  342. borderColor: '#e5e5e5',
  343. },
  344. fieldSetting: [], //单据字段设置
  345. // 任务编码
  346. rwbmTitle: "任务",
  347. rwbmFlag: "rwbm",
  348. // 职员
  349. zyTitle: "职员",
  350. zyFlag: "zy",
  351. // 客户
  352. khTitle: "客户",
  353. khFlag: "kh",
  354. // 部门
  355. bmTitle: "部门",
  356. bmFlag: "bm",
  357. // 收发类别
  358. sflbTitle: "收发类别",
  359. sflbFlag: "sflb",
  360. // 供应商
  361. gysTitle: "供应商",
  362. gysFlag: "gys",
  363. // 托盘
  364. tpTitle: "托盘",
  365. tpFlag: "tp",
  366. // 包装
  367. bzTitle: "包装",
  368. bzFlag: "bz",
  369. //配合$noMultipleClicks防止重复点击
  370. noClick:true,
  371. }
  372. },
  373. methods: {
  374. upper: function(e) {
  375. },
  376. lower: function(e) {
  377. },
  378. scroll: function(e) {
  379. this.old.scrollTop = e.detail.scrollTop
  380. },
  381. async retryRequest(requestFunction, requestParams, maxRetries = 1) {
  382. let retriesLeft = maxRetries;
  383. while (retriesLeft > 0) {
  384. try {
  385. // 调用请求函数并传入参数
  386. const response = await requestFunction(requestParams);
  387. if (response && response.code === 200) {
  388. return response; // 请求成功,返回响应
  389. } else {
  390. // 请求失败,但还有重试机会
  391. //console.warn(`请求失败,正在尝试第 ${maxRetries - retriesLeft + 1} 次重试...`);
  392. retriesLeft--;
  393. }
  394. } catch (error) {
  395. // 请求发生异常,但还有重试机会
  396. //console.error('请求发生异常,正在尝试重试...', error);
  397. retriesLeft--;
  398. }
  399. }
  400. // 所有重试都失败了,抛出错误
  401. throw new Error('获取信息失败');
  402. },
  403. onShow() {
  404. let that = this;
  405. uni.$off("scancode"); // 每次进来先 移除全局自定义事件监听器
  406. uni.$on("scancode", (data) => {
  407. // 扫描PCS码
  408. if(data && data !== ''){
  409. that.barCode = data;
  410. this.getDataByRemark(that.barCode);
  411. }else{
  412. uni.showToast({
  413. title: '扫码失败!',
  414. icon:'none',
  415. duration: 2000
  416. });
  417. }
  418. });
  419. },
  420. // 条码右侧扫码按钮事件
  421. handleScanClick:function(){
  422. let that = this;
  423. uni.scanCode({
  424. success: function(res) {
  425. // 播放音效
  426. // this.playMusic();
  427. // {"scanType":"QR_CODE","path":"","charSet":"ISO8859_1","result":"PT|04-A-1-1","errMsg":"scanCode:ok"}
  428. if(res.errMsg == "scanCode:ok"){
  429. that.barCode = res.result;
  430. this.getDataByRemark(that.barCode);
  431. }else{
  432. uni.showToast({
  433. title: '扫码失败!',
  434. icon:'none',
  435. duration: 2000
  436. });
  437. }
  438. },
  439. fail: (err) => {
  440. },
  441. complete: () => {
  442. }
  443. });
  444. },
  445. // 根据扫码数据查询其他formItem数据
  446. getDataByRemark(remark){
  447. let that = this;
  448. remark = remark.replace(/^\s+|\s+$/g, '');
  449. var splitPre = remark.split("|")[0];
  450. var splitLast = remark.slice(splitPre.length+1);
  451. // 条码空 不执行
  452. if(splitLast == ""){
  453. return true;
  454. }
  455. // 扫码
  456. switch (splitPre){
  457. case "PT": // 货位 PT|04-A-1-1
  458. this.getScanHwList(splitLast);
  459. break;
  460. case "WH": // 仓库 WH|01
  461. this.getScanCkList(splitLast);
  462. break;
  463. case "RW": // 任务扫码 RW|
  464. this.getScanRwList(splitLast);
  465. break;
  466. case "L": // 标签 L|L2311060002
  467. this.getScanBqList(splitLast);
  468. break;
  469. case "P": // 托盘 P|0002
  470. this.getScanTpList(splitLast);
  471. break;
  472. case "PA": // 包装 PA|0002
  473. this.getScanBzList(splitLast);
  474. break;
  475. default:
  476. uni.showToast({
  477. title: "条码不合法",
  478. icon: "none"
  479. })
  480. break;
  481. }
  482. },
  483. // 条码框 回车
  484. scanSearch(remark){
  485. this.getDataByRemark(remark);
  486. },
  487. async ywlxChange(value) {
  488. if(value === ''){
  489. this.formData.billTypeCode = "";
  490. this.formData.billTypeName = "";
  491. this.formData.taskBillTypeCode = "";
  492. this.formData.isControlTask = "";
  493. }else {
  494. let status = this.billTypeOption.find(item => item.value == value);
  495. if(status){
  496. this.formData.billTypeCode = status.value;
  497. this.formData.billTypeName = status.text;
  498. this.formData.taskBillTypeCode = status.taskValue;
  499. this.formData.isControlTask = status.isControlTask
  500. }
  501. }
  502. // 监听业务类型变更,变更后。清空任务、供应商、收发类别、清空明细查询出的数据、清空入库单号和单号数组
  503. //清空任务
  504. this.formData.taskOutsId = "";
  505. this.formData.backTaskOutsCode = "";
  506. this.formData.backTaskOutsId = "";
  507. //清空供应商
  508. this.formData.supplierCode = "";
  509. this.formData.supplierName = "";
  510. //清空收发类别
  511. this.formData.extendCode01 = "";
  512. this.formData.extendName01 = "";
  513. // 清空明细数据
  514. if (this.$refs.mxPopup) {
  515. this.$refs.mxPopup.listData = [];
  516. }
  517. // 清空入库单号和单号数组
  518. uni.removeStorageSync('stock_key');
  519. //更新唯一值
  520. this.formData.appGroupId = nanoid(19);
  521. if(value!='' && value!=null){
  522. //默认值
  523. const res = await this.retryRequest(listFieldDefault, { "billTypeCode":value, "billCode": 'backStockOut' });
  524. if(res.code === 200){
  525. let fieldDefault = res.rows; //字段默认值
  526. let fieldSetting = this.fieldSetting.filter(item => item.defaults == '1'); //字段信息
  527. let form = this.formData; //新增的信息
  528. /*
  529. * 遍历字段信息,如果字段默认值和头信息中存在,则用字段中的keyCode、keyName和默认值中的settingCode、settingName赋值给from
  530. */
  531. for (let i = 0; i < fieldSetting.length; i++) {
  532. let fieldD = fieldDefault.filter(item => item.settingFlag == fieldSetting[i].field);
  533. //如果字段默认值和头信息中存在
  534. if (fieldD.length>0 && fieldSetting[i].field in form) {
  535. //仓库触发一次扫码
  536. if(fieldD[0].settingFlag=="warehouseCode" && fieldD[0].settingCode){
  537. this.getScanCkList(fieldD[0].settingCode)
  538. continue
  539. }
  540. //赋值code(实际值)
  541. if(fieldSetting[i]["keyCode"]){
  542. form[ fieldSetting[i]["keyCode"] ] = fieldD[0].settingCode;
  543. }
  544. //赋值name(显示值)
  545. if(fieldSetting[i]["keyName"]){
  546. form[ fieldSetting[i]["keyName"] ] = fieldD[0].settingName;
  547. }
  548. }
  549. }
  550. }
  551. }
  552. },
  553. getSendData(res){ //基础资料
  554. let cFlag = res.currentFlag;
  555. switch (cFlag){
  556. case "rwbm": // 任务编码
  557. //任务
  558. this.formData.taskOutsId = res.selectData.wmsTaskOuts.taskOutsId;
  559. this.formData.backTaskOutsCode = res.selectData.wmsTaskOuts.subTaskCode;
  560. this.formData.backTaskOutsId = res.selectData.wmsTaskOuts.id;
  561. // 赋值部门
  562. this.formData.deptCode = res.selectData.deptCode;
  563. this.formData.deptName = res.selectData.deptName;
  564. // 赋值职员
  565. this.formData.employeeCode = res.selectData.employeeCode;
  566. this.formData.employeeName = res.selectData.employeeName;
  567. // 赋值供应商
  568. this.formData.supplierCode = res.selectData.supplierCode;
  569. this.formData.supplierName = res.selectData.supplierName;
  570. // 赋值物料、任务数量
  571. this.formData.materialCode = res.selectData.wmsTaskOuts.materialCode;
  572. this.formData.rwQty = (res.selectData.wmsTaskOuts.taskQty || 0) - (res.selectData.wmsTaskOuts.stockQty || 0);
  573. break;
  574. case "bm": // 部门
  575. this.formData.deptCode = res.selectData.deptCode;
  576. this.formData.deptName = res.selectData.deptName;
  577. // 职员清空
  578. this.formData.employeeCode = "";
  579. this.formData.employeeName = "";
  580. break;
  581. case "zy": // 职员
  582. this.formData.employeeCode = res.selectData.employeeCode;
  583. this.formData.employeeName = res.selectData.employeeName;
  584. break;
  585. case "kh": // 客户
  586. this.formData.customerCode = res.selectData.customerCode;
  587. this.formData.customerName = res.selectData.customerName;
  588. break;
  589. case "sflb": // 收发类别
  590. this.formData.extendName01 = res.selectData.extendName;
  591. this.formData.extendCode01 = res.selectData.extendCode;
  592. break;
  593. case "gys": // 供应商
  594. this.formData.supplierCode = res.selectData.supplierCode;
  595. this.formData.supplierName = res.selectData.supplierName;
  596. break;
  597. case "bz": // 包装
  598. this.formData.packageCode = res.selectData.packageCode;
  599. this.formData.packageName = res.selectData.packageName;
  600. if(res.selectData.warehouseCode){
  601. this.formData.warehouseCode = res.selectData.warehouseCode;
  602. this.formData.warehouseName = res.selectData.warehouseName;
  603. }
  604. if(res.selectData.locationCode){
  605. this.formData.locationCode = res.selectData.locationCode;
  606. this.formData.locationName = res.selectData.locationName;
  607. }
  608. if(res.selectData.palletCode){
  609. this.formData.palletCode = res.selectData.palletCode;
  610. this.formData.palletName = res.selectData.palletName;
  611. }
  612. break;
  613. case "tp": // 托盘
  614. this.formData.palletCode = res.selectData.palletCode;
  615. this.formData.palletName = res.selectData.palletName;
  616. if(res.selectData.warehouseCode){
  617. this.formData.warehouseCode = res.selectData.warehouseCode;
  618. this.formData.warehouseName = res.selectData.warehouseName;
  619. }
  620. if(res.selectData.locationCode){
  621. this.formData.locationCode = res.selectData.locationCode;
  622. this.formData.locationName = res.selectData.locationName;
  623. }
  624. this.formData.packageCode = '';
  625. this.formData.packageName = '';
  626. break;
  627. default:
  628. break;
  629. }
  630. },
  631. // easyinput后面放大镜点击
  632. searchIconClick(type){
  633. switch (type){
  634. case "task": // 任务编码
  635. this.$refs.rwbmPopup.showPopup();
  636. break;
  637. case "dept": // 部门
  638. this.$refs.bmPopup.showPopup();
  639. break;
  640. case "empl": // 职员
  641. this.$refs.zyPopup.showPopup();
  642. break;
  643. case "cust": // 客户
  644. this.$refs.khPopup.showPopup();
  645. break;
  646. case "supp": // 供应商
  647. this.$refs.gysPopup.showPopup();
  648. break;
  649. case "ext01": // 收发类别
  650. this.$refs.sflbPopup.showPopup();
  651. break;
  652. case "pall": // 托盘
  653. this.$refs.tpPopup.showPopup();
  654. break;
  655. case "pack": // 包装
  656. this.$refs.bzPopup.showPopup();
  657. break;
  658. default:
  659. break;
  660. }
  661. },
  662. remarkGetFocus(){
  663. this.remarkFocus = false;
  664. this.$nextTick(() => {
  665. this.remarkFocus = true
  666. })
  667. },
  668. setScan(str){//赋值条码框 光标聚焦
  669. this.barCode = str + "|";
  670. this.remarkGetFocus();
  671. },
  672. bqslInputHandle(value){
  673. let rwsl = this.formData.rwQty; //任务数量
  674. if(rwsl != ""){
  675. if(value > parseFloat(rwsl)){
  676. uni.showToast({
  677. title: "数量大于任务数量",
  678. icon: "none"
  679. })
  680. return;
  681. }
  682. }
  683. },
  684. // 下面工具栏 明细点击 事件
  685. handleMx(){
  686. this.$refs.mxPopup.showDrawer();
  687. },
  688. handleSave() {
  689. //获取信息失败时不可以保存
  690. if(this.isRequest==false){
  691. uni.showToast({
  692. title: '获取单据信息失败,请返回菜单重新进入',
  693. icon: "none"
  694. })
  695. return true;
  696. }
  697. if (this.isShowSaveButton) {
  698. uni.showToast({
  699. title: '保存中,请稍等',
  700. icon: 'none',
  701. duration:2000
  702. })
  703. }
  704. //如果唯一值空,生成唯一值
  705. if(this.formData.appGroupId=='' || this.formData.appGroupId==null){
  706. this.formData.appGroupId = nanoid(19)
  707. }
  708. let that = this;
  709. that.$refs.form.validate().then(res => {
  710. let wmsStockOutsArr = [];
  711. let tmpWms = {
  712. taskOutsId: that.formData.taskOutsId,// 任务
  713. backTaskOutsId: that.formData.backTaskOutsId,
  714. locationCode: that.formData.locationCode, // 货位编码
  715. labelCode:that.formData.labelCode, // 标签编码
  716. materialCode: that.formData.materialCode, // 物料编码
  717. batch: that.formData.batch, //批号
  718. palletCode: that.formData.palletCode, // 托盘编码
  719. unitCode: that.formData.unitCode, //单位编码
  720. stockQty: that.formData.stockQty, // 标签数量
  721. batch1: that.formData.batch1, //批号1
  722. batch2: that.formData.batch2, //批号2
  723. palletCode: that.formData.palletCode, // 托盘编码
  724. packageCode: that.formData.packageCode, // 包装编码
  725. isPackage: that.formData.isPackage,
  726. isPallet: that.formData.isPallet,
  727. };
  728. wmsStockOutsArr.push(tmpWms);
  729. let params = {
  730. guid: that.getHashId,
  731. appGroupId: that.formData.appGroupId,
  732. status: "1",
  733. stockType: "1",
  734. billTypeCode: that.formData.billTypeCode, // 单据类型
  735. deptCode: that.formData.deptCode, //部门
  736. employeeCode: that.formData.employeeCode, // 职员
  737. supplierCode : that.formData.supplierCode, //供应商
  738. customerCode : that.formData.customerCode, //客户
  739. extendCode01: that.formData.extendCode01, // 收发类别编码
  740. warehouseCode: that.formData.warehouseCode, // 仓库
  741. wmsBackStockOutsList: wmsStockOutsArr,
  742. isLocation: that.formData.isLocation
  743. }
  744. addStockOut(params).then(res => {
  745. if(res.code === 200){
  746. that.mxNum ++;
  747. // 保存单号
  748. if(res.msg !== ""){
  749. let storageData = uni.getStorageSync('stock_key');
  750. if(storageData){
  751. let stockIdList = storageData.stockIdList;
  752. stockIdList.push(res.msg);
  753. let data = {
  754. "stockId": res.msg,
  755. "stockIdList": stockIdList
  756. }
  757. uni.setStorageSync('stock_key', data);
  758. }else{
  759. let tmpList = [];
  760. tmpList.push(res.msg);
  761. let data = {
  762. "stockId": res.msg,
  763. "stockIdList": tmpList
  764. }
  765. uni.setStorageSync('stock_key', data);
  766. }
  767. }
  768. // 扫码后任务数量 - 标签数量
  769. let rwQty = that.formData.rwQty;
  770. if(rwQty!=0 && rwQty!="" && !isNaN(parseFloat(rwQty)) && isFinite(rwQty)){
  771. that.formData.rwQty = rwQty - that.formData.stockQty;
  772. }
  773. // 清空子表信息
  774. that.EmptyEntry();
  775. if (that.isShowSaveButton) {
  776. uni.showToast({
  777. title: '保存成功',
  778. icon: 'none',
  779. duration:2000
  780. })
  781. }
  782. }else{
  783. uni.vibrateLong({});
  784. uni.showToast({
  785. title: "保存失败!",
  786. icon: "none"
  787. })
  788. }
  789. }).catch((err) => {
  790. uni.vibrateLong({});
  791. });
  792. }).catch((err) => {
  793. uni.vibrateLong({});
  794. });
  795. },
  796. // 任务扫码请求
  797. getScanRwList(barCode){
  798. let that = this;
  799. let params = {
  800. supplierCode: that.formData.supplierCode, //供应商 (为空时不传)
  801. customerCode: that.formData.customerCode, //客户
  802. taskType: 1,
  803. billTypeCode:that.formData.taskBillTypeCode,
  804. params: {
  805. "barCode":barCode,
  806. "limit":1,
  807. "isControlTask": that.formData.isControlTask,
  808. },
  809. }
  810. listBackStockTaskOut(params).then(res => {
  811. if(res.code === 200){
  812. let data = res.rows ? res.rows[0] : {};
  813. if(data && Object.keys(data).length !== 0){
  814. // 赋值任务编号
  815. that.formData.taskOutsId = data.wmsTaskOuts.taskOutsId;
  816. that.formData.backTaskOutsCode = data.wmsTaskOuts.subTaskCode;
  817. that.formData.backTaskOutsId = data.wmsTaskOuts.id;
  818. // 赋值部门
  819. that.formData.deptCode = data.deptCode;
  820. that.formData.deptName = data.deptName;
  821. // 赋值职员
  822. that.formData.employeeCode = data.employeeCode;
  823. that.formData.employeeName = data.employeeName;
  824. // 赋值供应商
  825. that.formData.supplierCode = data.supplierCode;
  826. that.formData.supplierName = data.supplierName;
  827. // 赋值客户
  828. that.formData.customerCode = data.customerCode;
  829. that.formData.customerName = data.customerName;
  830. // 赋值物料、任务数量
  831. that.formData.materialCode = data.wmsTaskOuts.materialCode;
  832. that.formData.materialName = data.wmsTaskOuts.materialName;
  833. that.formData.materialSpecification = data.wmsTaskOuts.materialSpecification;
  834. that.formData.rwQty = (data.wmsTaskOuts.taskQty || 0) - (data.wmsTaskOuts.stockQty || 0);
  835. }else{
  836. uni.showToast({
  837. title: "无数据",
  838. icon: 'none',
  839. })
  840. that.formData.taskOutsId = "";
  841. that.formData.backTaskOutsCode = "";
  842. that.formData.backTaskOutsId = "";
  843. that.formData.deptCode = "";
  844. that.formData.deptName = "";
  845. that.formData.employeeCode = "";
  846. that.formData.employeeName = "";
  847. that.formData.supplierCode = "";
  848. that.formData.supplierName = "";
  849. that.formData.materialCode = "";
  850. }
  851. }
  852. });
  853. },
  854. //仓库扫码请求
  855. getScanCkList(barCode){
  856. let that = this;
  857. let params = {
  858. status: "0", // (固定)
  859. params: {
  860. "barCode":barCode,
  861. "limit":1
  862. },
  863. }
  864. // 仓库网络请求
  865. listWarehouse(params).then(res => {
  866. if(res.code === 200){
  867. let data = res.rows ? res.rows[0] : {};
  868. if(data && Object.keys(data).length !== 0){
  869. // 带出仓库编码、仓库名称、是否包含货位(is_location),如果is_location=1,隐藏货位
  870. // 赋值仓库、货位
  871. that.formData.warehouseCode = data.warehouseCode;
  872. that.formData.warehouseName = data.warehouseName;
  873. that.formData.locationCode = "";
  874. that.formData.locationName = "";
  875. // 是否显示货位
  876. let obj = {"field": "locationCode","fieldName": "货位","required": null,"requiredCondition": null,"hidden": null,"hiddenCondition": null}
  877. obj.required = data.isLocation == "1" ? null : 1;
  878. obj.hidden = data.isLocation == "1" ? 1 : null;
  879. that.formData.isLocation = data.isLocation;
  880. that.setFieldSetting(obj);
  881. // 清空包装托盘
  882. that.formData.palletCode = '';
  883. that.formData.palletName = '';
  884. that.formData.packageCode = '';
  885. that.formData.packageName = '';
  886. // 清空信息
  887. that.EmptyTest();
  888. that.EmptyEntry();
  889. that.formData.rwQty = "";
  890. }else if(this.barCode){
  891. uni.showToast({
  892. title: "无数据",
  893. icon: 'none',
  894. })
  895. }
  896. }
  897. });
  898. },
  899. //收发类别扫码请求(但不是给扫码用的,在加载时调用)
  900. getScanSflbList(barCode){
  901. let that = this;
  902. let params = {
  903. extendClassCode: "01.02",
  904. params: {
  905. "keyWord":barCode,
  906. "limit":1
  907. },
  908. }
  909. // 收发类别网络请求
  910. listExtend(params).then(res => {
  911. if(res.code === 200){
  912. let data = res.rows ? res.rows[0] : {};
  913. if(data && Object.keys(data).length !== 0){
  914. // 收发类别
  915. that.formData.extendCode01 = data.extendCode;
  916. that.formData.extendName01 = data.extendName;
  917. }else if(this.barCode){
  918. uni.showToast({
  919. title: "无数据",
  920. icon: "none"
  921. })
  922. }
  923. }
  924. });
  925. },
  926. //货位扫码请求
  927. getScanHwList(barCode){
  928. let that = this;
  929. let params = {
  930. status: "0", // (固定)
  931. params: {
  932. "barCode":barCode,
  933. "limit":1
  934. },
  935. }
  936. // 货位网络请求
  937. listLocation(params).then(res => {
  938. if(res.code === 200){
  939. let data = res.rows ? res.rows[0] : {};
  940. if(data && Object.keys(data).length !== 0){
  941. if(data.warehouseCode === that.formData.warehouseCode || '' == that.formData.warehouseCode ){ // 货位能对上仓库
  942. // 赋值货位、仓库
  943. that.formData.locationCode = data.locationCode;
  944. that.formData.locationName = data.locationName;
  945. that.formData.warehouseCode = data.warehouseCode;
  946. that.formData.warehouseName = data.warehouseName;
  947. // 显示货位
  948. let obj = {"field": "locationCode","fieldName": "货位","required": null,"requiredCondition": null,"hidden": null,"hiddenCondition": null}
  949. obj.required = 1;
  950. that.setFieldSetting(obj);
  951. that.formData.isLocation = 0
  952. // 清空包装托盘
  953. that.formData.palletCode = '';
  954. that.formData.palletName = '';
  955. that.formData.packageCode = '';
  956. that.formData.packageName = '';
  957. // 清空信息
  958. that.EmptyEntry();
  959. }else{ // 货位对不上仓库
  960. uni.showToast({
  961. title: "货位不属于当前仓库",
  962. icon: "none",
  963. duration: 3000
  964. })
  965. }
  966. }else{
  967. uni.showToast({
  968. title: "无数据",
  969. icon: 'none',
  970. })
  971. }
  972. }
  973. });
  974. },
  975. // 标签扫码请求
  976. getScanBqList(barCode){
  977. let that = this;
  978. let params = {
  979. params: {
  980. "barCode":barCode,
  981. "limit":1
  982. },
  983. BackTaskCode: that.formData.BackTaskCode, //任务
  984. }
  985. //有任务时传物料编码
  986. if(that.formData.BackTaskCode!=null && that.formData.BackTaskCode!='' && that.formData.BackTaskCode!=undefined){
  987. params.materialCode = that.formData.materialCode;
  988. }
  989. // 标签网络请求
  990. listBackStockOut(params).then(res => {
  991. if(res.code === 200){
  992. let data = res.rows ? res.rows[0] : {};
  993. if(data && Object.keys(data).length !== 0){
  994. // 赋值标签数量
  995. that.formData.stockQty = data.labelQty;
  996. if(that.formData.backTaskOutsCode == '' || that.formData.backTaskOutsCode == null){
  997. that.formData.rwQty = data.labelQty;
  998. }
  999. // 赋值标签
  1000. that.formData.labelCode = data.labelCode;
  1001. // 赋值物料编码,物料名称 , 规格
  1002. that.formData.materialName = data.materialName;
  1003. that.formData.materialCode = data.materialCode;
  1004. that.formData.materialSpecification = data.materialSpecification; //规格
  1005. // 赋值批号
  1006. that.formData.batch = data.batch;
  1007. that.formData.batch1 = data.batch1;
  1008. that.formData.batch2 = data.batch2;
  1009. // 赋值单位
  1010. that.formData.unitCode = data.unitCode;
  1011. that.formData.unitName = data.unitName;
  1012. //赋值是否托、是否包装
  1013. that.formData.isPackage = data.isPackage
  1014. that.formData.isPallet = data.isPallet
  1015. //如果不显示保存按钮则自动保存
  1016. if (!that.isShowSaveButton) {
  1017. setTimeout(() => {
  1018. that.handleSave();
  1019. },10)
  1020. }
  1021. }else{
  1022. uni.vibrateLong({});
  1023. uni.showToast({
  1024. title: "标签无效或已扫描",
  1025. icon: "none"
  1026. })
  1027. }
  1028. }
  1029. }).catch((err) => {
  1030. uni.vibrateLong({});
  1031. });
  1032. },
  1033. //托盘扫码请求
  1034. getScanTpList(barCode){
  1035. let that = this;
  1036. let params = {
  1037. status: "0", // (固定)
  1038. locationCode: this.formData.locationCode,
  1039. warehouseCode: this.formData.warehouseCode,
  1040. params: {
  1041. "barCode":barCode,
  1042. "limit":1
  1043. },
  1044. }
  1045. // 托盘网络请求
  1046. listPallet(params).then(res => {
  1047. if(res.code === 200){
  1048. let data = res.rows ? res.rows[0] : {};
  1049. if(data && Object.keys(data).length !== 0){
  1050. that.formData.palletCode = data.palletCode;
  1051. that.formData.palletName = data.palletName;
  1052. if(data.warehouseCode){
  1053. that.formData.warehouseCode = data.warehouseCode;
  1054. that.formData.warehouseName = data.warehouseName;
  1055. }
  1056. if(data.locationCode){
  1057. that.formData.locationCode = data.locationCode;
  1058. that.formData.locationName = data.locationName;
  1059. }
  1060. that.formData.packageCode = '';
  1061. that.formData.packageName = '';
  1062. }else{
  1063. uni.showToast({
  1064. title: "无数据",
  1065. icon: "none"
  1066. })
  1067. }
  1068. }
  1069. });
  1070. },
  1071. //包装扫码请求
  1072. getScanBzList(barCode){
  1073. let that = this;
  1074. let params = {
  1075. status: "0", // (固定)
  1076. locationCode: this.formData.locationCode,
  1077. warehouseCode: this.formData.warehouseCode,
  1078. palletCode: this.formData.palletCode,
  1079. params: {
  1080. "barCode":barCode,
  1081. "limit":1
  1082. },
  1083. }
  1084. // 包装网络请求
  1085. listPackage(params).then(res => {
  1086. if(res.code === 200){
  1087. let data = res.rows ? res.rows[0] : {};
  1088. if(data && Object.keys(data).length !== 0){
  1089. that.formData.packageCode = data.packageCode;
  1090. that.formData.packageName = data.packageName;
  1091. if(data.warehouseCode){
  1092. that.formData.warehouseCode = data.warehouseCode;
  1093. that.formData.warehouseName = data.warehouseName;
  1094. }
  1095. if(data.locationCode){
  1096. that.formData.locationCode = data.locationCode;
  1097. that.formData.locationName = data.locationName;
  1098. }
  1099. if(data.palletCode){
  1100. that.formData.palletCode = data.palletCode;
  1101. that.formData.palletName = data.palletName;
  1102. }
  1103. }else{
  1104. uni.showToast({
  1105. title: "无数据",
  1106. icon: "none"
  1107. })
  1108. }
  1109. }
  1110. });
  1111. },
  1112. handleAuto(){
  1113. if(this.autoButtonTitle === "自动"){ //手动
  1114. this.autoButtonTitle = "手动";
  1115. this.isShowSaveButton = true;
  1116. }else{ //自动
  1117. this.autoButtonTitle = "自动";
  1118. this.isShowSaveButton = false;
  1119. }
  1120. },
  1121. handleBack(){
  1122. uni.showModal({
  1123. title: '提示',
  1124. content: '确认返回?',
  1125. success: function (res) {
  1126. if (res.confirm) {
  1127. uni.navigateBack();
  1128. } else if (res.cancel) {
  1129. }
  1130. }
  1131. });
  1132. },
  1133. getSendNum(num){
  1134. this.mxNum = num;
  1135. if(num == 0){
  1136. this.formData.appGroupId=''
  1137. }
  1138. },
  1139. SendNumEmpty(){
  1140. let that = this;
  1141. if(this.mxNum>0){
  1142. uni.showModal({
  1143. title: '新单',
  1144. content: '是否要明细归零,录入新单?',
  1145. success: function (res) {
  1146. if (res.confirm) {
  1147. that.mxNum = 0;
  1148. let data = {
  1149. "stockId": "",
  1150. "stockIdList": []
  1151. }
  1152. uni.setStorageSync('stock_key', data);
  1153. //清空唯一值
  1154. that.formData.appGroupId = '';
  1155. }
  1156. }
  1157. });
  1158. }
  1159. },
  1160. EmptyTest(){ //清空任务信息
  1161. this.formData.taskOutsId = "";
  1162. this.formData.BackTaskCode = "";
  1163. this.formData.backTaskOutsId = "";
  1164. this.formData.materialCode = "";
  1165. this.formData.materialName = "";
  1166. this.formData.materialSpecification = "";
  1167. },
  1168. EmptyEntry(){ //清空子表信息
  1169. this.formData.labelCode = "";
  1170. this.formData.batch = "";
  1171. this.formData.unitCode = "";
  1172. this.formData.unitName = "";
  1173. this.formData.stockQty = "";
  1174. // this.formData.rwQty = "";
  1175. this.formData.batch1 = "";
  1176. this.formData.batch2 = "";
  1177. this.formData.palletCode = "";
  1178. this.formData.palletName = "";
  1179. this.formData.packageCode = "";
  1180. this.formData.packageName = "";
  1181. },
  1182. rulesStar(str){
  1183. let rules=this.rules;
  1184. if(rules[str] && rules[str].rules[0] && rules[str].rules[0].required){
  1185. return true;
  1186. }else{
  1187. return false;
  1188. }
  1189. },
  1190. fieldHidden(str){
  1191. let rules=this.rules;
  1192. if(rules[str] && rules[str].rules[0] && rules[str].rules[0].hidden){
  1193. return !true;
  1194. }else{
  1195. return !false;
  1196. }
  1197. },
  1198. setFieldSetting(obj){ //修改字段设置
  1199. let index = this.fieldSetting.findIndex(item => item.field == obj.field);
  1200. if (index !== -1) {
  1201. // 如果找到匹配项,则使用 obj 的属性覆盖 fieldSetting 中的相应属性
  1202. Object.assign(this.fieldSetting[index], obj);
  1203. } else {
  1204. // 如果没有找到匹配项,则将 obj 添加到 fieldSetting 中
  1205. this.fieldSetting.push(obj);
  1206. }
  1207. },
  1208. },
  1209. computed: {
  1210. rules() {
  1211. let form = this.formData;
  1212. let rules = {};
  1213. if(!Array.isArray(this.fieldSetting) && this.fieldSetting.length>0){
  1214. return rules;
  1215. }
  1216. //转数组
  1217. for(let i=0;i<this.fieldSetting.length;i++){
  1218. let field = this.fieldSetting[i];
  1219. rules[field.field] = {
  1220. rules: [{ required: false, errorMessage: field.fieldName + '不能为空', hidden: false }],
  1221. }
  1222. if(field.required==1 && field.field){ //判断是否必录
  1223. //判断是否必录
  1224. if(!field.requiredCondition){ //条件为空
  1225. rules[field.field].rules[0].required = true;
  1226. }else{ //有条件;form中对应属性满足正则
  1227. //先赋值true;正则不满足再赋值false
  1228. rules[field.field].rules[0].required = true;
  1229. //判断必录用正则数组
  1230. let regArr = [];
  1231. try {
  1232. if(field.requiredCondition){
  1233. let arr = JSON.parse(field.requiredCondition);
  1234. if(arr!=null){
  1235. regArr = arr.map(([key, value]) => [key, new RegExp(value)]);
  1236. }
  1237. }
  1238. }catch(err) {
  1239. console.error("err",err)
  1240. }
  1241. for(let j=0;j<regArr.length;j++){
  1242. if(regArr[j].length==2 && regArr[j][1].test( form[regArr[j][0]] )){
  1243. rules[field.field].rules[0].required = true;
  1244. }else{
  1245. rules[field.field].rules[0].required = false;
  1246. break;
  1247. }
  1248. }
  1249. }
  1250. }
  1251. if(field.hidden==1 && field.field){ //判断是否隐藏
  1252. //判断是否必录
  1253. if(!field.hiddenCondition){ //条件为空
  1254. rules[field.field].rules[0].hidden = true;
  1255. }else{ //有条件;form中对应属性满足正则
  1256. //先赋值true;正则不满足再赋值false
  1257. rules[field.field].rules[0].hidden = true;
  1258. //判断必录用正则数组
  1259. let regArr = [];
  1260. try {
  1261. if(field.hiddenCondition){
  1262. let arr = JSON.parse(field.hiddenCondition);
  1263. if(arr!=null){
  1264. regArr = arr.map(([key, value]) => [key, new RegExp(value)]);
  1265. }
  1266. }
  1267. }catch(err) {
  1268. console.error("err",err)
  1269. }
  1270. for(let j=0;j<regArr.length;j++){
  1271. if(regArr[j].length==2 && regArr[j][1].test( form[regArr[j][0]] )){
  1272. rules[field.field].rules[0].hidden = true;
  1273. }else{
  1274. rules[field.field].rules[0].hidden = false;
  1275. break;
  1276. }
  1277. }
  1278. }
  1279. }
  1280. }
  1281. return rules;
  1282. },
  1283. getHashId(){
  1284. //生成哈希值
  1285. const crypto = require('crypto');
  1286. function hashString(str) {
  1287. const hash = crypto.createHash('sha256');
  1288. hash.update(str);
  1289. return hash.digest('hex');
  1290. }
  1291. //null和undefined返回空
  1292. function IFNULL(str){
  1293. return (str==null || str==undefined) ? "" : str + "";
  1294. }
  1295. //使用头信息和nanoid来生成唯一值
  1296. let groupJson = {
  1297. appGroupId : this.formData.appGroupId,
  1298. billTypeCode : IFNULL(this.formData.billTypeCode),
  1299. backTaskOutId : '',
  1300. deptCode : IFNULL(this.formData.deptCode),
  1301. employeeCode : IFNULL(this.formData.employeeCode),
  1302. supplierCode : IFNULL(this.formData.supplierCode),
  1303. warehouseCode : IFNULL(this.formData.warehouseCode),
  1304. customerCode : IFNULL(this.formData.customerCode),
  1305. extendCode01 : IFNULL(this.formData.extendCode01),
  1306. extendCode02 : IFNULL(this.formData.extendCode02),
  1307. extendCode03 : IFNULL(this.formData.extendCode03),
  1308. extendCode04 : IFNULL(this.formData.extendCode04),
  1309. extendCode05 : IFNULL(this.formData.extendCode05),
  1310. }
  1311. let groupStr = JSON.stringify(groupJson)
  1312. const hash = hashString(groupStr)
  1313. return hash
  1314. },
  1315. },
  1316. }
  1317. </script>
  1318. <style>
  1319. @import "@/static/scss/stock.css";
  1320. </style>