27d3ae27edb4b4c71f88fb752ccd28f46775f6f2.svn-base 58 KB

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