index.vue 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" :range-separator="$t('common.to')" :start-placeholder="$t('common.startTime')" :end-placeholder="$t('common.endTime')" style="width: 250px;" />
  5. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  6. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  7. <el-select v-model="table.getdataListParm.parammaps.feedid" filterable:placeholder="$t('InventoryManagement.silc')" class="filter-item" style="width: 150px;" clearable>
  8. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  9. </el-select>
  10. <el-select v-model="table.getdataListParm.parammaps.providerid" placeholder="供应商" class="filter-item" style="width: 150px;" clearable>
  11. <el-option v-for="item in supplierList" :key="item.id" :label="item.providerName" :value="item.id" />
  12. </el-select>
  13. <el-select v-model="table.getdataListParm.parammaps.islaid" placeholder="是否入库" class="filter-item" style="width: 150px;" clearable>
  14. <el-option v-for="item in islaidList" :key="item.id" :label="item.name" :value="item.id" />
  15. </el-select>
  16. <el-button class="successBorder" @click="form_search">{{$t('common.query')}}</el-button>
  17. <el-button class="successBorder" @click="handleRefresh">{{$t('common.reset')}}</el-button>
  18. </div>
  19. <div class="operation">
  20. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">新增入库单</el-button>
  21. <el-upload style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  22. <el-button v-if="isRoleEdit" class="import" icon="el-icon-download" style="float: right;">{{$t('formulationEvaluation.enter')}}</el-button>
  23. </el-upload>
  24. <el-dropdown style="float: right;margin-right: 10px;">
  25. <el-button class="export" icon="el-icon-upload2">{{$t('formulationEvaluation.out')}}</el-button>
  26. <el-dropdown-menu slot="dropdown">
  27. <el-dropdown-item @click.native="handleExport(1)">{{$t('formulationEvaluation.outmb')}}</el-dropdown-item>
  28. <el-dropdown-item @click.native="handleExport(2)">{{$t('formulationEvaluation.outsj')}}</el-dropdown-item>
  29. </el-dropdown-menu>
  30. </el-dropdown>
  31. </div>
  32. <div class="table">
  33. <el-table
  34. :key="table.tableKey"
  35. v-loading="table.listLoading"
  36. :element-loading-text="$t('common.tableMsg')"
  37. :data="table.list"
  38. border
  39. fit
  40. highlight-current-row
  41. style="width: 100%;"
  42. :row-style="rowStyle"
  43. :cell-style="cellStyle"
  44. class="elTable table-fixed"
  45. :max-height="myHeight"
  46. >
  47. <el-table-column :label="$t('formulationEvaluation.xh')" align="center" type="index" width="50px">
  48. <template slot-scope="scope">
  49. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="入库日期" min-width="90px" align="center">
  53. <template slot-scope="scope">
  54. <span>{{ scope.row.laiddate }}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column :label="$t('InventoryManagement.silc')" min-width="90px" align="center">
  58. <template slot-scope="scope">
  59. <span>{{ scope.row.feedname }}</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="供应商" min-width="90px" align="center">
  63. <template slot-scope="scope">
  64. <span>{{ scope.row.providername }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="入库重量(kg)" min-width="90px" align="center">
  68. <template slot-scope="scope">
  69. <span>{{ scope.row.operateweight }}</span>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="总价(元)" min-width="90px" align="center">
  73. <template slot-scope="scope">
  74. <span>{{ scope.row.sumprice }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="批号" min-width="90px" align="center">
  78. <template slot-scope="scope">
  79. <span>{{ scope.row.pcpde }}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column :label="$t('formulationEvaluation.remark')" min-width="90px" align="center">
  83. <template slot-scope="scope">
  84. <span>{{ scope.row.remark }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="入库状态" min-width="90px" align="center">
  88. <template slot-scope="scope">
  89. <span>{{ scope.row.islaid }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column :label="$t('role.cjr')" min-width="90px" align="center">
  93. <template slot-scope="scope">
  94. <span>{{ scope.row.createemp }}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="创建日期" min-width="90px" align="center">
  98. <template slot-scope="scope">
  99. <span>{{ scope.row.createdate }}</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column :label="$t('errorAnalysis.cz')" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  103. <template slot-scope="{row}">
  104. <el-button class="miniSuccess" icon="el-icon-search" @click="form_see(row)" />
  105. <el-button v-if="row.islaid == '否'" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  110. </div>
  111. <!-- 新增入库单 -->
  112. <el-dialog :fullscreen="dialogFull" :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" v-if='create.dialogFormVisible' :close-on-click-modal="false" width="90%">
  113. <template slot="title">
  114. <div class="avue-crud__dialog__header">
  115. <span class="el-dialog__title">
  116. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  117. {{ textMap[create.dialogStatus] }}
  118. </span>
  119. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  120. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  121. <svg-icon v-else icon-class="fullscreen" />
  122. </div>
  123. </div>
  124. </template>
  125. <div class="app-add">
  126. <el-form ref="createTemp" :rules="create.rules" :model="create.createTemp" label-position="right" label-width="160px" style="width: 100%;margin:0 auto">
  127. <el-row>
  128. <el-col :span="24">
  129. <h3 style="width: 160px;text-align: right;">{{$t('feedChart.jcxx')}}</h3>
  130. </el-col>
  131. </el-row>
  132. <el-row>
  133. <el-col :span="8">
  134. <el-form-item label="入库日期:" prop="laiddate">
  135. <el-date-picker v-model="create.createTemp.laiddate" :disabled="create.dialogStatus=='see'" class="filter-item" type="date" placeholder="入库日期" :clearable="false" :picker-options="create.pickerOptions1" format="yyyy-MM-dd" value-format="yyyy-MM-dd" />
  136. </el-form-item>
  137. </el-col>
  138. <el-col :span="8">
  139. <el-form-item label="送货单编号:" prop="wagonnumber">
  140. <el-input ref="wagonnumber" v-model="create.createTemp.wagonnumber" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="送货单编号" type="text" />
  141. </el-form-item>
  142. </el-col>
  143. <el-col :span="8">
  144. <el-form-item label="饲料名称:" prop="feedname">
  145. <el-autocomplete
  146. v-model="create.createTemp.feedname"
  147. value-key="fname"
  148. class="inline-input"
  149. :fetch-suggestions="feedNameSearch"
  150. placeholder="请选择饲料名称"
  151. style="width:98%"
  152. :disabled="create.dialogStatus=='see' || create.dialogStatus=='update'"
  153. @select="handleSelectFeedName"
  154. @blur="blurFeedName"
  155. >
  156. <template slot-scope="{ item }">
  157. <span>{{ item.fname }}</span>
  158. </template>
  159. </el-autocomplete>
  160. </el-form-item>
  161. </el-col>
  162. </el-row>
  163. <el-row>
  164. <el-col :span="8">
  165. <el-form-item label="入库重量(kg):" prop="operateweight">
  166. <el-input ref="operateweight" v-model.trim="create.createTemp.operateweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurOperateweight" />
  167. </el-form-item>
  168. </el-col>
  169. <el-col :span="8">
  170. <el-form-item label="供应商:" prop="providerid">
  171. <el-input v-if="create.dialogStatus=='see'" ref="providername" v-model.trim="create.createTemp.providername" disabled class="filter-item" placeholder="请选择供应商" />
  172. <el-select v-else v-model="create.createTemp.providerid" clearable placeholder="请选择供应商" :disabled="create.dialogStatus=='see'" class="filter-item" style="width: 100%" @change="changeSupplier">
  173. <el-option v-for="item in supplierList" :key="item.id" :label="item.providerName" :value="item.id" />
  174. </el-select>
  175. </el-form-item>
  176. </el-col>
  177. <el-col :span="8">
  178. <el-form-item label="合同编号:" prop="contractcode">
  179. <el-select v-model="create.createTemp.contractcode" clearable placeholder="请选择合同编号" :disabled="create.dialogStatus=='see'" class="filter-item" style="width: 100%" @change="changeContractNo">
  180. <el-option v-for="item in contractNoList" :key="item.id" :label="item.contractcodeCat" :value="item.contractcode" />
  181. </el-select>
  182. </el-form-item>
  183. </el-col>
  184. </el-row>
  185. <el-row>
  186. <el-col :span="24">
  187. <h3 style="width: 160px;text-align: right;">价格信息</h3>
  188. </el-col>
  189. </el-row>
  190. <el-row>
  191. <el-col :span="8">
  192. <el-form-item label="单价(元):" prop="pricenew">
  193. <el-input ref="pricenew" v-model="create.createTemp.pricenew" :disabled="create.createTemp.contractcode !=='' || create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurPricenew" />
  194. </el-form-item>
  195. </el-col>
  196. <el-col :span="8">
  197. <el-form-item label="总价(元):" prop="sumprice">
  198. <el-input ref="sumprice" v-model="create.createTemp.sumprice" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurSumprice" />
  199. </el-form-item>
  200. </el-col>
  201. </el-row>
  202. <el-row>
  203. <el-col :span="24">
  204. <h3 style="width: 160px;text-align: right;">{{$t('formulationEvaluation.feed')}}信息</h3>
  205. </el-col>
  206. </el-row>
  207. <el-row>
  208. <el-col :span="8">
  209. <el-form-item label="毛重(kg):" prop="grossweight">
  210. <el-input ref="grossweight" v-model.trim="create.createTemp.grossweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurGrossweight" />
  211. </el-form-item>
  212. </el-col>
  213. <el-col :span="8">
  214. <el-form-item label="皮重(kg):" prop="tareweight">
  215. <el-input ref="tareweight" v-model.trim="create.createTemp.tareweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurTareweight" />
  216. </el-form-item>
  217. </el-col>
  218. <el-col :span="8">
  219. <el-form-item label="许可证号:" prop="licence">
  220. <el-input ref="licence" v-model="create.createTemp.licence" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="许可证号" type="text" />
  221. </el-form-item>
  222. </el-col>
  223. </el-row>
  224. <el-row>
  225. <el-col :span="8">
  226. <el-form-item label="批号:" prop="pcpde">
  227. <el-input ref="pcpde" v-model="create.createTemp.pcpde" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="批号" type="text" />
  228. </el-form-item>
  229. </el-col>
  230. </el-row>
  231. <el-row>
  232. <el-col :span="24">
  233. <h3 style="width: 160px;text-align: right;">操作信息</h3>
  234. </el-col>
  235. </el-row>
  236. <el-row>
  237. <el-col :span="8">
  238. <el-form-item label="创建人:" prop="createemp">
  239. <el-input ref="createemp" v-model="create.createTemp.createemp" class="filter-item" :placeholder="$t('role.cjr')" type="text" disabled />
  240. </el-form-item>
  241. </el-col>
  242. <el-col :span="8">
  243. <el-form-item label="创建日期:" prop="createdate">
  244. <el-date-picker v-model="create.createTemp.createdate" class="filter-item" type="date" placeholder="创建日期" disabled />
  245. </el-form-item>
  246. </el-col>
  247. <el-col :span="8">
  248. <el-form-item label="备注:" prop="remark">
  249. <el-input ref="remark" v-model="create.createTemp.remark" :disabled="create.dialogStatus=='see'" class="filter-item"
  250. :placeholder="$t('supplier.zf3')" type="text" />
  251. </el-form-item>
  252. </el-col>
  253. </el-row>
  254. </el-form>
  255. <div slot="footer" class="dialog-footer">
  256. <el-button v-if="create.dialogStatus == 'see' " class="cancelClose cancelClose1" @click="create.dialogFormVisible = false;getList(); ">{{$t('common.closed')}}</el-button>
  257. <el-button v-if="create.dialogStatus !== 'see' " class="cancelClose" @click="create.dialogFormVisible = false;getList(); ">{{$t('common.closed')}}</el-button>
  258. <el-button v-if="create.dialogStatus !== 'see' " class="save" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">{{$t('errorAnalysis.confirm')}}</el-button>
  259. </div>
  260. </div>
  261. </el-dialog>
  262. <!-- 初始化库存 -->
  263. <el-dialog :fullscreen="dialogFull" :visible.sync="initial.dialogFormVisible" :close-on-click-modal="false" width="80%" height="55%">
  264. <template slot="title">
  265. <div class="avue-crud__dialog__header">
  266. <span class="el-dialog__title">
  267. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  268. {{ textMap[initial.dialogStatus] }}
  269. </span>
  270. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  271. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  272. <svg-icon v-else icon-class="fullscreen" />
  273. </div>
  274. </div>
  275. </template>
  276. <div class="app-add" style="height: 100%;margin: 0 auto 60px;">
  277. <div class="operation">
  278. <el-button style="float: left;margin-bottom:10px;" class="success" @click="handleInitialExport">模板下载</el-button>
  279. <el-upload style="float: left;margin-left: 10px;margin-bottom:10px;" action="" :auto-upload="false" accept=".xlsx, .xls" :show-file-list="false" :on-change="handleInitialImport">
  280. <el-button class="success" icon="el-icon-download">{{$t('formulationEvaluation.enter')}}</el-button>
  281. </el-upload>
  282. </div>
  283. <div class="table">
  284. <el-table
  285. :key="initial.tableKey"
  286. v-loading="initial.listLoading"
  287. :element-loading-text="$t('common.tableMsg')"
  288. :data="initial.list"
  289. border
  290. fit
  291. highlight-current-row
  292. style="width: 100%;"
  293. :row-style="rowStyle"
  294. :cell-style="cellStyle"
  295. class="elTable table-fixed"
  296. >
  297. <el-table-column :label="$t('formulationEvaluation.xh')" align="center" type="index" width="50px" />
  298. <el-table-column :label="$t('InventoryManagement.silc')" min-width="130px" align="center">
  299. <template slot-scope="scope">
  300. <span>{{ scope.row.fname }}</span>
  301. </template>
  302. </el-table-column>
  303. <el-table-column label="库存重量" min-width="130px" align="center">
  304. <template slot-scope="scope">
  305. <el-input v-model="scope.row.stockweight" placeholder="最多两位小数" type="number" :step="0.01" style="width:95%;padding:10px 0;" />
  306. </template>
  307. </el-table-column>
  308. </el-table>
  309. <div slot="footer" class="dialog-footer">
  310. <el-button class="cancelClose" @click="initial.dialogFormVisible = false; ">{{$t('common.closed')}}</el-button>
  311. <el-button class="save" :disabled="isokDisable" @click="initialData()">{{$t('errorAnalysis.confirm')}}</el-button>
  312. </div>
  313. </div>
  314. </div>
  315. </el-dialog>
  316. </div>
  317. </template>
  318. <script>
  319. import { GetDataByName, GetDataByNames, checkButtons, ExecDataByConfig, failproccess, formatNum } from '@/api/common'
  320. import Pagination from '@/components/Pagination'
  321. import { MessageBox } from 'element-ui'
  322. import Cookies from 'js-cookie'
  323. import { json2excel, parseTime } from '@/utils/index.js'
  324. import axios from 'axios'
  325. import { getToken } from '@/utils/auth'
  326. import xlsx from 'xlsx'
  327. import { upload } from '@/utils/index.js'
  328. export default {
  329. name: 'Warehousing',
  330. components: { Pagination },
  331. data() {
  332. return {
  333. dialogFull: false,
  334. feedNameList: [], // 饲料名称
  335. feedNameAddList: [], // 饲料名称新增
  336. supplierList: [], // 供应商
  337. contractNoList: [], // 合同编号
  338. islaidList: [ { id: 0, name: '未入库' },{ id: 1, name: '已入库' }], // 是否入库
  339. requestParams: [
  340. { name: 'getFeedListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  341. { name: 'getProviderListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  342. ],
  343. table: {
  344. getdataListParm: {
  345. name: 'getFeedlaidList',
  346. page: 1,
  347. offset: 1,
  348. pagecount: parseInt(Cookies.get('pageCount')),
  349. returntype: 'Map',
  350. parammaps: {
  351. pastureid: Cookies.get('pastureid'),
  352. inputDatetime: '',
  353. startTime: '',
  354. stopTime: '',
  355. feedid: '',
  356. islaid: '',
  357. providerid: ''
  358. }
  359. },
  360. tableKey: 0,
  361. list: [],
  362. total: 0,
  363. listLoading: true
  364. },
  365. create: {
  366. dialogFormVisible: false,
  367. dialogStatus: '',
  368. pickerOptions1: {
  369. disabledDate(time) {
  370. return time.getTime() > Date.now()// 当天之前的时间可选
  371. }
  372. },
  373. createTemp: {
  374. laiddate: '', feedid: '', feedname: '', operateweight: '', providerid: '', providername: '', startweight: '', priceold: '', contractcode: '', pricenew: '', sumprice: '', grossweight: '', tareweight: '', licence: '', pcpde: '', createemp: '', createdate: '', remark: '', 'wagonnumber': ''
  375. },
  376. rules: {
  377. laiddate: [{ type: 'string', required: true, message: this.$t('hardwareTest.bt'), trigger: 'blur' }],
  378. operateweight: [{ type: 'string', required: true, message: this.$t('hardwareTest.bt'), trigger: 'blur' }],
  379. feedname: [{ type: 'string', required: true, message: this.$t('hardwareTest.bt'), trigger: 'change' }],
  380. pricenew: [{ type: 'string', required: true, message: this.$t('hardwareTest.bt'), trigger: 'blur' }]
  381. },
  382. getdataListParm: {
  383. name: 'getBigContractListEnable',
  384. offset: 0,
  385. pagecount: '',
  386. parammaps: { pastureid: Cookies.get('pastureid') }
  387. },
  388. getfeedNameParm: {
  389. name: 'getFeedListEnableV2',
  390. offset: 0,
  391. pagecount: '',
  392. parammaps: { pastureid: Cookies.get('pastureid') }
  393. }
  394. },
  395. initial: {
  396. dialogFormVisible: false,
  397. dialogStatus: '',
  398. rules: {},
  399. getdataListParm: {
  400. name: 'getinitFeed',
  401. page: 1,
  402. offset: 1,
  403. pagecount: 6,
  404. returntype: 'Map',
  405. parammaps: {
  406. pastureid: Cookies.get('pastureid')
  407. }
  408. },
  409. tableKey: 0,
  410. list: [],
  411. total: 0,
  412. listLoading: true,
  413. character: {
  414. fname: {
  415. text: '饲料名称',
  416. type: String
  417. },
  418. stockweight: {
  419. text: '库存重量',
  420. type: String
  421. }
  422. }
  423. },
  424. textMap: {
  425. create: '新增入库单',
  426. update: '编辑入库单',
  427. see: '查看入库单',
  428. initial: '初始化库存'
  429. },
  430. requestParam: {},
  431. download: {
  432. getdataListParm: {
  433. name: 'getFeedlaidList',
  434. page: 1,
  435. offset: 1,
  436. pagecount: 0,
  437. returntype: 'Map',
  438. parammaps: {
  439. pastureid: Cookies.get('pastureid'),
  440. inputDatetime: '',
  441. startTime: '',
  442. stopTime: '',
  443. feedid: '',
  444. islaid: '',
  445. providerid: ''
  446. }
  447. },
  448. list: []
  449. },
  450. isokDisable: false,
  451. isRoleEdit: [],
  452. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  453. cellStyle: { padding: 0 + 'px' },
  454. myHeight:document.documentElement.clientHeight - 85- 150 - 45
  455. }
  456. },
  457. computed: {
  458. // 设置请求头
  459. headers() {
  460. return {
  461. token: getToken()
  462. }
  463. },
  464. uploadData() {
  465. return {
  466. name: 'checkFeed,checkProviderRK,checkcontractcode,checkcontractcodePrice,insertFeedlaidUpload,insertFeedstorageLaidUpload',
  467. importParams: '入库日期,送货单编号,饲料名称,供应商,合同编号,入库重量(kg),单价(元),总价(元),毛重(kg),皮重(kg),许可证号,批号,创建人,备注',
  468. sheetname: 'Sheet1',
  469. // 登录牧场
  470. pastureid: Cookies.get('pastureid'),
  471. // 日期参数
  472. dateParams: '入库日期',
  473. // 必填参数
  474. requiredParams: '入库日期,饲料名称,入库重量(kg),单价(元)',
  475. // 为数值的参数
  476. numParams: '入库重量(kg),单价(元),总价(元),毛重(kg),皮重(kg)'
  477. }
  478. },
  479. // 设置上传地址
  480. uploadExcelUrl() {
  481. return Cookies.get('url') + 'authdata/ImportExcel'
  482. }
  483. },
  484. created() {
  485. this.getButtons()
  486. this.getDownList()
  487. this.getList()
  488. },
  489. methods: {
  490. getButtons() {
  491. const Edit = 'Warehousing'
  492. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  493. this.isRoleEdit = isRoleEdit
  494. },
  495. getDownList() {
  496. GetDataByNames(this.requestParams).then(response => {
  497. this.feedNameList = response.data.getFeedListEnable.list
  498. this.supplierList = response.data.getProviderListEnable.list
  499. })
  500. },
  501. handleBefore() {
  502. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  503. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  504. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  505. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  506. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  507. this.$forceUpdate()
  508. }
  509. },
  510. handleNext() {
  511. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  512. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  513. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  514. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  515. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  516. this.$forceUpdate()
  517. }
  518. },
  519. getList() {
  520. this.table.listLoading = true
  521. GetDataByName(this.table.getdataListParm).then(response => {
  522. console.log('table数据', response.data.list)
  523. if (response.data.list !== null) {
  524. this.table.list = response.data.list
  525. this.table.pageNum = response.data.pageNum
  526. this.table.pageSize = response.data.pageSize
  527. } else {
  528. this.table.list = []
  529. }
  530. this.table.total = response.data.total
  531. setTimeout(() => {
  532. this.table.listLoading = false
  533. }, 100)
  534. })
  535. },
  536. form_search() {
  537. // console.log('点击了查询')
  538. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  539. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  540. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  541. } else {
  542. this.table.getdataListParm.parammaps.inputDatetime = ''
  543. this.table.getdataListParm.parammaps.startTime = ''
  544. this.table.getdataListParm.parammaps.stopTime = ''
  545. }
  546. this.table.getdataListParm.offset = 1
  547. this.getList()
  548. },
  549. handleRefresh() {
  550. console.log('点击了重置')
  551. this.table.getdataListParm.parammaps.inputDatetime = ''
  552. this.table.getdataListParm.parammaps.startTime = ''
  553. this.table.getdataListParm.parammaps.stopTime = ''
  554. this.table.getdataListParm.parammaps.feedid = ''
  555. this.table.getdataListParm.parammaps.islaid = ''
  556. this.table.getdataListParm.parammaps.providerid = ''
  557. this.table.getdataListParm.offset = 1
  558. this.getList()
  559. },
  560. resetCreateTemp() {
  561. this.create.createTemp = {
  562. pastureid: Cookies.get('pastureid'), laiddate: parseTime(new Date(), '{y}-{m}-{d}'), feedid: '', feedname: '', operateweight: '', providerid: '', providername: '', startweight: '', priceold: '', contractcode: '', pricenew: '', sumprice: '', grossweight: '', tareweight: '', licence: '', pcpde: '', createemp: Cookies.get('employename'), createdate: parseTime(new Date(), '{y}-{m}-{d}'), remark: '', 'wagonnumber': ''
  563. }
  564. this.contractNoList = []
  565. },
  566. // 供应商
  567. changeSupplier(item) {
  568. console.log(item)
  569. if (item !== '') {
  570. this.create.createTemp.providername = this.supplierList.find(obj => obj.id == item).providerName
  571. } else {
  572. this.create.createTemp.providername = ''
  573. this.create.createTemp.contractcode = ''
  574. this.create.createTemp.pricenew = ''
  575. this.create.createTemp.sumprice = ''
  576. this.contractNoList = []
  577. }
  578. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  579. this.getContractNoList()
  580. }
  581. },
  582. // 合同编号
  583. changeContractNo(item) {
  584. if (item !== '') {
  585. this.create.createTemp.pricenew = this.contractNoList.find(obj => obj.contractcode == item).price
  586. } else {
  587. this.create.createTemp.pricenew = ''
  588. }
  589. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  590. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  591. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  592. }
  593. },
  594. getContractNoList() {
  595. this.create.getdataListParm.parammaps.feedid = this.create.createTemp.feedid
  596. this.create.getdataListParm.parammaps.providerid = this.create.createTemp.providerid
  597. GetDataByName(this.create.getdataListParm).then(response => {
  598. console.log('table数据', response.data.list)
  599. if (response.data.list !== null) {
  600. this.contractNoList = response.data.list
  601. this.create.createTemp.contractcode = ''
  602. this.create.createTemp.pricenew = ''
  603. this.create.createTemp.sumprice = ''
  604. } else {
  605. this.contractNoList = []
  606. this.create.createTemp.contractcode = ''
  607. this.create.createTemp.pricenew = ''
  608. this.create.createTemp.sumprice = ''
  609. }
  610. })
  611. },
  612. feedNameSearch(queryString, cb) {
  613. this.create.getfeedNameParm.parammaps['fname'] = queryString
  614. GetDataByName(this.create.getfeedNameParm).then(response => {
  615. console.log('模糊查询搜索data', response.data.list)
  616. if (response.data.list == null) {
  617. cb([])
  618. } else {
  619. cb(response.data.list)
  620. }
  621. })
  622. },
  623. handleSelectFeedName(item) {
  624. console.log('模糊查询选中值', item)
  625. this.create.createTemp.feedname = item.fname
  626. this.create.createTemp.feedid = item.id
  627. this.create.createTemp.startweight = item.stockweight
  628. this.create.createTemp.priceold = item.price
  629. this.create.createTemp.providerid = ''
  630. this.create.createTemp.providername = ''
  631. this.create.createTemp.contractcode = ''
  632. this.create.createTemp.pricenew = ''
  633. this.create.createTemp.sumprice = ''
  634. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  635. this.getContractNoList()
  636. }
  637. },
  638. blurFeedName() {
  639. this.create.createTemp.feedname = ''
  640. this.create.createTemp.feedid = ''
  641. this.create.createTemp.startweight = ''
  642. this.create.createTemp.priceold = ''
  643. this.create.createTemp.providerid = ''
  644. this.create.createTemp.providername = ''
  645. this.create.createTemp.contractcode = ''
  646. this.create.createTemp.pricenew = ''
  647. this.create.createTemp.sumprice = ''
  648. },
  649. // 入库重量
  650. blurOperateweight() {
  651. // 毛重grossweight皮重tareweight入库重量operateweight
  652. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  653. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight), 2)
  654. }
  655. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  656. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  657. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  658. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  659. }
  660. }
  661. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  662. if (this.create.createTemp.operateweight == '') {
  663. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  664. }
  665. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  666. this.create.createTemp.tareweight = formatNum(this.create.createTemp.grossweight, 2)
  667. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  668. }
  669. }
  670. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  671. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  672. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  673. } else {
  674. this.create.createTemp.sumprice = ''
  675. }
  676. },
  677. // 毛重
  678. blurGrossweight() {
  679. // 毛重grossweight皮重tareweight入库重量operateweight
  680. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  681. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight), 2)
  682. }
  683. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  684. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  685. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  686. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  687. }
  688. }
  689. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  690. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  691. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  692. } else {
  693. this.create.createTemp.sumprice = ''
  694. }
  695. },
  696. // 皮重
  697. blurTareweight() {
  698. // 毛重grossweight皮重tareweight入库重量operateweight
  699. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.tareweight !== '') {
  700. this.create.createTemp.grossweight = formatNum(parseFloat(this.create.createTemp.tareweight) + parseFloat(this.create.createTemp.operateweight), 2)
  701. }
  702. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  703. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  704. this.create.createTemp.grossweight = formatNum(this.create.createTemp.operateweight, 2)
  705. this.create.createTemp.tareweight = formatNum(parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight), 2)
  706. }
  707. }
  708. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  709. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  710. this.create.createTemp.tareweight = formatNum(this.create.createTemp.grossweight, 2)
  711. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  712. } else {
  713. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight), 2)
  714. }
  715. }
  716. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  717. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  718. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  719. } else {
  720. this.create.createTemp.sumprice = ''
  721. }
  722. },
  723. // 单价
  724. blurPricenew() {
  725. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  726. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  727. this.create.createTemp.sumprice = formatNum(this.create.createTemp.sumprice, 2)
  728. } else {
  729. this.create.createTemp.sumprice = ''
  730. }
  731. },
  732. // 总价
  733. blurSumprice() {
  734. if (this.create.createTemp.sumprice !== '' && this.create.createTemp.pricenew !== '') {
  735. this.create.createTemp.operateweight = formatNum(parseFloat(this.create.createTemp.sumprice) / parseFloat(this.create.createTemp.pricenew), 2)
  736. } else {
  737. this.create.createTemp.operateweight = ''
  738. }
  739. },
  740. handleCreate() {
  741. console.log('点击了新增入库单')
  742. this.dialogFull = false
  743. this.create.dialogStatus = 'create'
  744. this.create.dialogFormVisible = true
  745. this.$nextTick(() => {
  746. this.resetCreateTemp()
  747. this.$refs.createTemp.resetFields()
  748. })
  749. },
  750. createData() {
  751. this.$refs['createTemp'].validate(valid => {
  752. if (valid) {
  753. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  754. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  755. return false
  756. }
  757. if (this.create.createTemp.sumprice.length > 15) {
  758. this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
  759. }
  760. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  761. // 入库重量
  762. if (this.create.createTemp.operateweight !== '') {
  763. if (this.create.createTemp.operateweight == 0) {
  764. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  765. return false
  766. } else {
  767. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  768. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  769. return false
  770. }
  771. }
  772. }
  773. // 单价
  774. if (this.create.createTemp.pricenew == 0) {
  775. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  776. return false
  777. } else {
  778. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  779. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  780. return false
  781. }
  782. }
  783. // 总价
  784. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  785. if (this.create.createTemp.sumprice == 0) {
  786. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  787. return false
  788. } else {
  789. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  790. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  791. return false
  792. }
  793. }
  794. }
  795. // 毛重
  796. if (this.create.createTemp.grossweight !== '') {
  797. if (this.create.createTemp.grossweight == 0) {
  798. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  799. return false
  800. } else {
  801. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  802. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  803. return false
  804. }
  805. }
  806. }
  807. // 皮重
  808. if (this.create.createTemp.tareweight !== '') {
  809. if (this.create.createTemp.tareweight == 0) {
  810. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  811. return false
  812. } else {
  813. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  814. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  815. return false
  816. }
  817. }
  818. }
  819. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: this.$t('common.confirm'), confirmButtonText: this.$t('common.cancel'), type: 'warning'
  820. }).then(() => {
  821. this.isokDisable = true
  822. setTimeout(() => {
  823. this.isokDisable = false
  824. }, 1000)
  825. this.requestParam.common = { 'returnmap': '0' }
  826. this.requestParam.data = []
  827. this.requestParam.data[0] = { 'name': 'insertFeedlaid', 'type': 'e', 'parammaps': {
  828. 'pastureid': this.create.createTemp.pastureid,
  829. 'laiddate': this.create.createTemp.laiddate,
  830. 'feedid': this.create.createTemp.feedid,
  831. 'feedname': this.create.createTemp.feedname,
  832. 'providerid': this.create.createTemp.providerid,
  833. 'providername': this.create.createTemp.providername,
  834. 'contractcode': this.create.createTemp.contractcode,
  835. 'operateweight': this.create.createTemp.operateweight,
  836. 'grossweight': this.create.createTemp.grossweight,
  837. 'tareweight': this.create.createTemp.tareweight,
  838. 'sumprice': this.create.createTemp.sumprice,
  839. 'licence': this.create.createTemp.licence,
  840. 'pcpde': this.create.createTemp.pcpde,
  841. 'remark': this.create.createTemp.remark,
  842. 'createdate': this.create.createTemp.createdate,
  843. 'createemp': this.create.createTemp.createemp,
  844. 'startweight': this.create.createTemp.startweight,
  845. 'priceold': this.create.createTemp.priceold,
  846. 'pricenew': this.create.createTemp.pricenew,
  847. 'wagonnumber': this.create.createTemp.wagonnumber
  848. }}
  849. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  850. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  851. 'operateweight': this.create.createTemp.operateweight,
  852. 'pastureid': this.create.createTemp.pastureid,
  853. 'feedid': this.create.createTemp.feedid,
  854. 'fname': this.create.createTemp.fname,
  855. 'pcpde': this.create.createTemp.pcpde,
  856. 'stockweight': this.create.createTemp.startweight,
  857. 'price': this.create.createTemp.pricenew
  858. }}
  859. }
  860. console.log('点击了新增入库单保存', this.requestParam)
  861. ExecDataByConfig(this.requestParam).then(response => {
  862. if (response.msg === 'fail') {
  863. this.$notify({ title: this.$t('driver.saveFail'), message: response.data, type: 'warning', duration: 2000 })
  864. } else {
  865. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  866. this.create.dialogFormVisible = false
  867. this.getList()
  868. }
  869. })
  870. })
  871. }
  872. })
  873. },
  874. handleUpdate(row) {
  875. console.log('点击了编辑')
  876. this.$nextTick(() => {
  877. this.$refs.createTemp.resetFields()
  878. })
  879. this.dialogFull = false
  880. this.create.dialogStatus = 'update'
  881. this.create.dialogFormVisible = true
  882. row.feedid = String(row.feedid)
  883. if (row.providerid == -1) {
  884. row.providerid = ''
  885. row.providername = ''
  886. }
  887. this.create.createTemp = Object.assign({}, row)
  888. },
  889. updateData() {
  890. this.$refs['createTemp'].validate(valid => {
  891. if (valid) {
  892. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  893. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  894. return false
  895. }
  896. if (this.create.createTemp.sumprice.length > 15) {
  897. this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
  898. }
  899. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  900. // 入库重量
  901. if (this.create.createTemp.operateweight !== '') {
  902. if (this.create.createTemp.operateweight == 0) {
  903. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  904. return false
  905. } else {
  906. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  907. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  908. return false
  909. }
  910. }
  911. }
  912. // 单价
  913. if (this.create.createTemp.pricenew == 0) {
  914. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  915. return false
  916. } else {
  917. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  918. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  919. return false
  920. }
  921. }
  922. // 总价
  923. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  924. if (this.create.createTemp.sumprice == 0) {
  925. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  926. return false
  927. } else {
  928. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  929. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  930. return false
  931. }
  932. }
  933. }
  934. // 毛重
  935. if (this.create.createTemp.grossweight !== '') {
  936. if (this.create.createTemp.grossweight == 0) {
  937. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  938. return false
  939. } else {
  940. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  941. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  942. return false
  943. }
  944. }
  945. }
  946. // 皮重
  947. if (this.create.createTemp.tareweight !== '') {
  948. if (this.create.createTemp.tareweight == 0) {
  949. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  950. return false
  951. } else {
  952. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  953. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  954. return false
  955. }
  956. }
  957. }
  958. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: this.$t('common.confirm'), confirmButtonText: this.$t('common.cancel'), type: 'warning'
  959. }).then(() => {
  960. this.isokDisable = true
  961. setTimeout(() => {
  962. this.isokDisable = false
  963. }, 1000)
  964. this.requestParam.common = { 'returnmap': '0' }
  965. this.requestParam.data = []
  966. this.requestParam.data[0] = { 'name': 'updateFeedlaid', 'type': 'e', 'parammaps': {
  967. 'pastureid': this.create.createTemp.pastureid,
  968. 'id': this.create.createTemp.id,
  969. 'laiddate': this.create.createTemp.laiddate,
  970. 'feedid': this.create.createTemp.feedid,
  971. 'feedname': this.create.createTemp.feedname,
  972. 'providerid': this.create.createTemp.providerid,
  973. 'providername': this.create.createTemp.providername,
  974. 'contractcode': this.create.createTemp.contractcode,
  975. 'operateweight': this.create.createTemp.operateweight,
  976. 'grossweight': this.create.createTemp.grossweight,
  977. 'tareweight': this.create.createTemp.tareweight,
  978. 'sumprice': this.create.createTemp.sumprice,
  979. 'licence': this.create.createTemp.licence,
  980. 'pcpde': this.create.createTemp.pcpde,
  981. 'remark': this.create.createTemp.remark,
  982. 'createdate': this.create.createTemp.createdate,
  983. 'createemp': this.create.createTemp.createemp,
  984. 'startweight': this.create.createTemp.startweight,
  985. 'priceold': this.create.createTemp.priceold,
  986. 'pricenew': this.create.createTemp.pricenew,
  987. 'wagonnumber': this.create.createTemp.wagonnumber
  988. }}
  989. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  990. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  991. 'operateweight': this.create.createTemp.operateweight,
  992. 'pastureid': this.create.createTemp.pastureid,
  993. 'feedid': this.create.createTemp.feedid,
  994. 'fname': this.create.createTemp.fname,
  995. 'pcpde': this.create.createTemp.pcpde,
  996. 'stockweight': this.create.createTemp.startweight,
  997. 'price': this.create.createTemp.pricenew
  998. }}
  999. }
  1000. console.log('点击了新增入库单保存', this.requestParam)
  1001. ExecDataByConfig(this.requestParam).then(response => {
  1002. if (response.msg === 'fail') {
  1003. this.$notify({ title: this.$t('driver.saveFail'), message: response.data, type: 'warning', duration: 2000 })
  1004. } else {
  1005. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  1006. this.create.dialogFormVisible = false
  1007. this.getList()
  1008. }
  1009. })
  1010. })
  1011. }
  1012. })
  1013. },
  1014. form_see(row) {
  1015. console.log('点击了查看')
  1016. this.$nextTick(() => {
  1017. this.$refs.createTemp.resetFields()
  1018. })
  1019. this.dialogFull = false
  1020. this.create.dialogStatus = 'see'
  1021. this.create.dialogFormVisible = true
  1022. if (row.providerid == -1) {
  1023. row.providerid = ''
  1024. row.providername = ''
  1025. }
  1026. this.create.createTemp = Object.assign({}, row)
  1027. },
  1028. handleInitial() {
  1029. console.log('点击了初始化库存')
  1030. this.dialogFull = false
  1031. this.initial.dialogStatus = 'initial'
  1032. this.initial.dialogFormVisible = true
  1033. this.getInitialList()
  1034. },
  1035. getInitialList() {
  1036. this.initial.listLoading = true
  1037. GetDataByName(this.initial.getdataListParm).then(response => {
  1038. console.log('table数据', response.data.list)
  1039. if (response.data.list !== null) {
  1040. this.initial.list = response.data.list
  1041. this.initial.pageNum = response.data.pageNum
  1042. this.initial.pageSize = response.data.pageSize
  1043. this.initial.total = response.data.total
  1044. } else {
  1045. this.initial.list = []
  1046. }
  1047. setTimeout(() => {
  1048. this.initial.listLoading = false
  1049. }, 100)
  1050. })
  1051. },
  1052. handleInitialExport() {
  1053. console.log('点击了初始化库存导出')
  1054. const ExcelDatas = [
  1055. {
  1056. tHeader: ['饲料名称', '库存重量'],
  1057. filterVal: ['fname', 'stockweight'],
  1058. tableDatas: this.initial.list,
  1059. sheetName: '初始化库存'
  1060. }
  1061. ]
  1062. json2excel(ExcelDatas, '初始化库存', true, 'xlsx')
  1063. },
  1064. async handleInitialImport(eve) {
  1065. const file = eve.raw
  1066. if (!file) return
  1067. let reader = await upload(file)
  1068. const worker = xlsx.read(reader, { type: 'binary' })
  1069. // 将返回的数据转换为json对象的数据
  1070. reader = xlsx.utils.sheet_to_json(worker.Sheets[worker.SheetNames[0]])
  1071. console.log(reader)
  1072. const arr = []
  1073. reader.forEach(item => {
  1074. const obj = {}
  1075. for (const key in this.initial.character) {
  1076. if (!this.initial.character.hasOwnProperty(key)) break
  1077. let v = this.initial.character[key]
  1078. const text = v.text
  1079. const type = v.type
  1080. v = item[text] || ''
  1081. type === 'string' ? (v = String(v)) : null
  1082. type === 'number' ? (v = Number(v)) : null
  1083. obj[key] = v
  1084. }
  1085. arr.push(obj)
  1086. })
  1087. console.log('导入处理后数据', arr)
  1088. var sum = 0
  1089. for (let i = 0; i < this.initial.list.length; i++) {
  1090. for (let j = 0; j < arr.length; j++) {
  1091. if (this.initial.list[i].fname == arr[j].fname) {
  1092. this.initial.list[i].stockweight = arr[j].stockweight
  1093. sum++
  1094. arr.splice(j, 1)
  1095. }
  1096. }
  1097. }
  1098. console.log(arr)
  1099. for (let i = 0; i < arr.length; i++) {
  1100. this.$set(arr[i], 'msg', '饲料名称与系统不匹配')
  1101. }
  1102. console.log(sum)
  1103. this.$message({ title: this.$t('common.succes'), message:this.$t('message.msg5') + sum + this.$t('message.msg39'), type: 'success', duration: 2000 })
  1104. this.$notify({ title:this.$t('message.msg37'), message: this.$t('message.msg38') + arr.length + this.$t('message.msg39'), type: 'danger', duration: 2000 })
  1105. if (arr.length > 0) {
  1106. const ExcelDatas1 = [
  1107. {
  1108. tHeader: ['饲料名称', '库存重量', '报错信息'],
  1109. filterVal: ['fname', 'stockweight', 'msg'],
  1110. tableDatas: arr,
  1111. sheetName: 'ExcelDatas1'
  1112. }
  1113. ]
  1114. json2excel(ExcelDatas1, '初始化库存报错信息', true, 'xlsx')
  1115. }
  1116. },
  1117. initialData() {
  1118. console.log('点击了初始化库存保存')
  1119. this.isokDisable = true
  1120. setTimeout(() => {
  1121. this.isokDisable = false
  1122. }, 1000)
  1123. var rulesStockweight = /^\d+(\.\d{1,2})?$/
  1124. for (let i = 0; i < this.initial.list.length; i++) {
  1125. if (!rulesStockweight.test(parseFloat(this.initial.list[i].stockweight))) {
  1126. this.$message({ type: 'warning', message: '库存重量不可小于0,且保留俩位小数', duration: 2000 })
  1127. return false
  1128. }
  1129. }
  1130. this.requestParam.common = { 'returnmap': '0' }
  1131. this.requestParam.data = []
  1132. this.requestParam.data[0] = { 'name': 'clearFS', 'type': 'e', 'parammaps': {
  1133. 'pastureid': Cookies.get('pastureid')
  1134. }}
  1135. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.initial.list }}
  1136. this.requestParam.data[1].children = []
  1137. this.requestParam.data[1].children[0] = { 'name': 'insertFeedstorage', 'type': 'e', 'parammaps': {
  1138. pastureid: '@insertSpotList.pastureid',
  1139. feedid: '@insertSpotList.feedid',
  1140. fname: '@insertSpotList.fname',
  1141. pcpde: '@insertSpotList.pcpde',
  1142. stockweight: '@insertSpotList.stockweight',
  1143. price: '@insertSpotList.price'
  1144. }}
  1145. ExecDataByConfig(this.requestParam).then(response => {
  1146. if (response.msg === 'fail') {
  1147. this.$notify({ title: this.$t('driver.saveFail'), message: response.data, type: 'warning', duration: 2000 })
  1148. } else {
  1149. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  1150. this.create.dialogFormVisible = false
  1151. this.getList()
  1152. }
  1153. })
  1154. },
  1155. // 导出
  1156. handleExport(item) {
  1157. if (item == 1) {
  1158. console.log('点击了导出模板')
  1159. const requestParam = this.requestParam
  1160. const url = Cookies.get('url') + 'file/导入导出模板/库存管理/入库导入模板.xlsx' // 请求下载文件的地址
  1161. console.log(url)
  1162. axios({
  1163. method: 'GET',
  1164. url: url,
  1165. data: requestParam,
  1166. headers: { token: getToken(), optname: 'insertcustomdoc' },
  1167. responseType: 'blob'
  1168. }).then(res => {
  1169. if (!res) return
  1170. this.percentage = 99
  1171. setTimeout(() => {
  1172. this.isPercentage = false
  1173. }, 2000)
  1174. const blob = new Blob([res.data], {
  1175. type: 'application/octet-stream;charset=utf-8'
  1176. })
  1177. const url = window.URL.createObjectURL(blob)
  1178. const aLink = document.createElement('a')
  1179. aLink.style.display = 'none'
  1180. aLink.href = url
  1181. const docname = '入库管理导入模板.xlsx'
  1182. aLink.setAttribute('download', docname) // 下载的文件
  1183. document.body.appendChild(aLink)
  1184. aLink.click()
  1185. document.body.removeChild(aLink)
  1186. window.URL.revokeObjectURL(url)
  1187. })
  1188. } else {
  1189. console.log('点击了导出数据')
  1190. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1191. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  1192. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  1193. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  1194. } else {
  1195. this.download.getdataListParm.parammaps.inputDatetime = ''
  1196. this.download.getdataListParm.parammaps.startTime = ''
  1197. this.download.getdataListParm.parammaps.stopTime = ''
  1198. }
  1199. GetDataByName(this.download.getdataListParm).then(response => {
  1200. if (response.data.list !== null) {
  1201. this.download.list = response.data.list
  1202. } else {
  1203. this.download.list = []
  1204. }
  1205. var excelDatas = [
  1206. {
  1207. tHeader: ['入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注'],
  1208. filterVal: ['laiddate', 'wagonnumber', 'feedname', 'providername', 'contractcode', 'operateweight', 'pricenew', 'sumprice', 'grossweight', 'tareweight', 'licence', 'pcpde', 'createemp', 'createdate', 'remark'],
  1209. tableDatas: this.download.list,
  1210. sheetName: 'Sheet1'
  1211. }
  1212. ]
  1213. json2excel(excelDatas, '入库管理', true, 'xlsx')
  1214. })
  1215. }
  1216. },
  1217. beforeImport(file) {
  1218. const isLt2M = file.size / 1024 / 1024 < 2
  1219. if (!isLt2M) {
  1220. this.$message.error('上传文件大小不能超过 2MB!')
  1221. }
  1222. return isLt2M
  1223. },
  1224. handleImportSuccess(res, file) {
  1225. this.getList()
  1226. if (res.msg === 'ok') {
  1227. this.$message({ title: this.$t('common.succes'), message:this.$t('message.msg5') + res.data.success + this.$t('message.msg39'), type: 'success', duration: 2000 })
  1228. if (res.data.err_count > 0) {
  1229. this.$notify({ title:this.$t('message.msg38'), message: this.$t('message.msg38') + res.data.err_count + this.$t('message.msg39'), type: 'danger', duration: 2000 })
  1230. import('@/vendor/Export2Excel').then(excel => {
  1231. const list1 = res.data.result
  1232. const tHeader = [
  1233. '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', '错误信息'
  1234. ]
  1235. const filterVal = [
  1236. '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', 'error_msg'
  1237. ]
  1238. const data1 = this.formatJson(filterVal, list1)
  1239. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '入库管理导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1240. })
  1241. }
  1242. } else {
  1243. this.$notify({ title:this.$t('message.msg37'), message: this.$t('message.msg40'), type: 'danger', duration: 2000 })
  1244. }
  1245. },
  1246. formatJson(filterVal, jsonData) {
  1247. return jsonData.map(v =>
  1248. filterVal.map(j => {
  1249. if (j === 'timestamp') {
  1250. return parseTime(v[j])
  1251. } else {
  1252. return v[j]
  1253. }
  1254. })
  1255. )
  1256. }
  1257. }
  1258. }
  1259. </script>