ade3253627f2f1ee8f11982df5da8678c892b22e.svn-base 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  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 } 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 { getToken } from '@/utils/auth'
  298. import xlsx from 'xlsx'
  299. import { upload } from '@/utils/index.js'
  300. export default {
  301. name: 'Warehousing',
  302. components: { Pagination },
  303. data() {
  304. return {
  305. feedNameList: [], // 饲料名称
  306. feedNameAddList: [], // 饲料名称新增
  307. supplierList: [], // 供应商
  308. contractNoList: [], // 合同编号
  309. islaidList: [{ id: 0, name: '是' }, { id: 1, name: '否' }], // 是否入库
  310. requestParams: [
  311. { name: 'getFeedListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  312. { name: 'getProviderListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  313. ],
  314. table: {
  315. getdataListParm: {
  316. name: 'getFeedlaidList',
  317. page: 1,
  318. offset: 1,
  319. pagecount: 10,
  320. returntype: 'Map',
  321. parammaps: {
  322. pastureid: Cookies.get('pastureid'),
  323. inputDatetime: '',
  324. startTime: '',
  325. stopTime: '',
  326. feedid: '',
  327. islaid: '',
  328. providerid: ''
  329. }
  330. },
  331. tableKey: 0,
  332. list: [],
  333. total: 0,
  334. listLoading: true
  335. },
  336. create: {
  337. dialogFormVisible: false,
  338. dialogStatus: '',
  339. pickerOptions1: {
  340. disabledDate(time) {
  341. return time.getTime() > Date.now()// 当天之前的时间可选
  342. }
  343. },
  344. createTemp: {
  345. laiddate: '', feedid: '', feedname: '', operateweight: '', providerid: '', providername: '', startweight: '', priceold: '', contractcode: '', pricenew: '', sumprice: '', grossweight: '', tareweight: '', licence: '', pcpde: '', createemp: '', createdate: '', remark: '', 'wagonnumber': ''
  346. },
  347. rules: {
  348. laiddate: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  349. feedname: [{ type: 'string', required: true, message: '必填', trigger: 'change' }],
  350. pricenew: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  351. },
  352. getdataListParm: {
  353. name: 'getBigContractListEnable',
  354. offset: 0,
  355. pagecount: '',
  356. parammaps: { pastureid: Cookies.get('pastureid') }
  357. },
  358. getfeedNameParm: {
  359. name: 'getFeedListEnableV2',
  360. offset: 0,
  361. pagecount: '',
  362. parammaps: { pastureid: Cookies.get('pastureid') }
  363. }
  364. },
  365. initial: {
  366. dialogFormVisible: false,
  367. dialogStatus: '',
  368. rules: {},
  369. getdataListParm: {
  370. name: 'getinitFeed',
  371. page: 1,
  372. offset: 1,
  373. pagecount: 6,
  374. returntype: 'Map',
  375. parammaps: {
  376. pastureid: Cookies.get('pastureid')
  377. }
  378. },
  379. tableKey: 0,
  380. list: [],
  381. total: 0,
  382. listLoading: true,
  383. character: {
  384. fname: {
  385. text: '饲料名称',
  386. type: String
  387. },
  388. stockweight: {
  389. text: '库存重量',
  390. type: String
  391. }
  392. }
  393. },
  394. textMap: {
  395. create: '新增入库单',
  396. update: '编辑入库单',
  397. see: '查看入库单',
  398. initial: '初始化库存'
  399. },
  400. requestParam: {},
  401. download: {
  402. getdataListParm: {
  403. name: 'getFeedlaidList',
  404. page: 1,
  405. offset: 1,
  406. pagecount: 0,
  407. returntype: 'Map',
  408. parammaps: {
  409. pastureid: Cookies.get('pastureid'),
  410. inputDatetime: '',
  411. startTime: '',
  412. stopTime: '',
  413. feedid: '',
  414. islaid: '',
  415. providerid: ''
  416. }
  417. },
  418. list: []
  419. },
  420. isokDisable: false,
  421. isRoleEdit: [],
  422. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  423. cellStyle: { padding: 0 + 'px' }
  424. }
  425. },
  426. computed: {
  427. // 设置请求头
  428. headers() {
  429. return {
  430. token: getToken()
  431. }
  432. },
  433. uploadData() {
  434. return {
  435. name: '颛孙洋洋-入库',
  436. importParams: '入库日期,送货单编号,饲料名称,供应商,合同编号,入库重量(kg),单价(元),总价(元),毛重(kg),皮重(kg),许可证号,批号,创建人,创建日期,备注',
  437. sheetname: 'SheetJS'
  438. }
  439. },
  440. // 设置上传地址
  441. uploadExcelUrl() {
  442. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  443. }
  444. },
  445. created() {
  446. this.getButtons()
  447. this.getDownList()
  448. this.getList()
  449. },
  450. methods: {
  451. getButtons() {
  452. const Edit = 'Warehousing'
  453. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  454. this.isRoleEdit = isRoleEdit
  455. },
  456. getDownList() {
  457. GetDataByNames(this.requestParams).then(response => {
  458. this.feedNameList = response.data.getFeedListEnable.list
  459. this.supplierList = response.data.getProviderListEnable.list
  460. })
  461. },
  462. handleBefore() {
  463. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  464. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  465. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  466. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  467. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  468. this.$forceUpdate()
  469. }
  470. },
  471. handleNext() {
  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. getList() {
  481. this.table.listLoading = true
  482. GetDataByName(this.table.getdataListParm).then(response => {
  483. console.log('table数据', response.data.list)
  484. if (response.data.list !== null) {
  485. this.table.list = response.data.list
  486. this.table.pageNum = response.data.pageNum
  487. this.table.pageSize = response.data.pageSize
  488. this.table.total = response.data.total
  489. } else {
  490. this.table.list = []
  491. }
  492. setTimeout(() => {
  493. this.table.listLoading = false
  494. }, 100)
  495. })
  496. },
  497. handleSearch() {
  498. // console.log('点击了查询')
  499. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  500. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  501. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  502. } else {
  503. this.table.getdataListParm.parammaps.inputDatetime = ''
  504. this.table.getdataListParm.parammaps.startTime = ''
  505. this.table.getdataListParm.parammaps.stopTime = ''
  506. }
  507. this.table.getdataListParm.offset = 1
  508. this.getList()
  509. },
  510. handleRefresh() {
  511. console.log('点击了重置')
  512. this.table.getdataListParm.parammaps.inputDatetime = ''
  513. this.table.getdataListParm.parammaps.startTime = ''
  514. this.table.getdataListParm.parammaps.stopTime = ''
  515. this.table.getdataListParm.parammaps.feedid = ''
  516. this.table.getdataListParm.parammaps.islaid = ''
  517. this.table.getdataListParm.parammaps.providerid = ''
  518. this.table.getdataListParm.offset = 1
  519. },
  520. resetCreateTemp() {
  521. this.create.createTemp = {
  522. 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': ''
  523. }
  524. this.contractNoList = []
  525. },
  526. // 供应商
  527. changeSupplier(item) {
  528. console.log(item)
  529. if (item !== '') {
  530. this.create.createTemp.providername = this.supplierList.find(obj => obj.id == item).providerName
  531. } else {
  532. this.create.createTemp.providername = ''
  533. this.create.createTemp.contractcode = ''
  534. this.create.createTemp.pricenew = ''
  535. this.create.createTemp.sumprice = ''
  536. this.contractNoList = []
  537. }
  538. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  539. this.getContractNoList()
  540. }
  541. },
  542. // 合同编号
  543. changeContractNo(item) {
  544. if (item !== '') {
  545. this.create.createTemp.pricenew = this.contractNoList.find(obj => obj.contractcode == item).price
  546. } else {
  547. this.create.createTemp.pricenew = ''
  548. }
  549. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  550. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  551. this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
  552. }
  553. },
  554. getContractNoList() {
  555. this.create.getdataListParm.parammaps.feedid = this.create.createTemp.feedid
  556. this.create.getdataListParm.parammaps.providerid = this.create.createTemp.providerid
  557. GetDataByName(this.create.getdataListParm).then(response => {
  558. console.log('table数据', response.data.list)
  559. if (response.data.list !== null) {
  560. this.contractNoList = response.data.list
  561. this.create.createTemp.contractcode = ''
  562. this.create.createTemp.pricenew = ''
  563. this.create.createTemp.sumprice = ''
  564. } else {
  565. this.contractNoList = []
  566. this.create.createTemp.contractcode = ''
  567. this.create.createTemp.pricenew = ''
  568. this.create.createTemp.sumprice = ''
  569. }
  570. })
  571. },
  572. feedNameSearch(queryString, cb) {
  573. this.create.getfeedNameParm.parammaps['fname'] = queryString
  574. GetDataByName(this.create.getfeedNameParm).then(response => {
  575. console.log('模糊查询搜索data', response.data.list)
  576. if (response.data.list == null) {
  577. cb([])
  578. } else {
  579. cb(response.data.list)
  580. }
  581. })
  582. },
  583. handleSelectFeedName(item) {
  584. console.log('模糊查询选中值', item)
  585. this.create.createTemp.feedname = item.fname
  586. this.create.createTemp.feedid = item.id
  587. this.create.createTemp.startweight = item.stockweight
  588. this.create.createTemp.priceold = item.price
  589. this.create.createTemp.providerid = ''
  590. this.create.createTemp.providername = ''
  591. this.create.createTemp.contractcode = ''
  592. this.create.createTemp.pricenew = ''
  593. this.create.createTemp.sumprice = ''
  594. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  595. this.getContractNoList()
  596. }
  597. },
  598. blurFeedName() {
  599. this.create.createTemp.feedname = ''
  600. this.create.createTemp.feedid = ''
  601. this.create.createTemp.startweight = ''
  602. this.create.createTemp.priceold = ''
  603. this.create.createTemp.providerid = ''
  604. this.create.createTemp.providername = ''
  605. this.create.createTemp.contractcode = ''
  606. this.create.createTemp.pricenew = ''
  607. this.create.createTemp.sumprice = ''
  608. },
  609. // 入库重量
  610. blurOperateweight() {
  611. // 毛重grossweight皮重tareweight入库重量operateweight
  612. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  613. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight)
  614. }
  615. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  616. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  617. this.create.createTemp.grossweight = this.create.createTemp.operateweight
  618. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight)
  619. }
  620. }
  621. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  622. if (this.create.createTemp.operateweight == '') {
  623. this.create.createTemp.operateweight = (parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight))
  624. }
  625. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  626. this.create.createTemp.tareweight = this.create.createTemp.grossweight
  627. this.create.createTemp.operateweight = (parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight))
  628. }
  629. }
  630. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  631. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  632. this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
  633. } else {
  634. this.create.createTemp.sumprice = ''
  635. }
  636. },
  637. // 毛重
  638. blurGrossweight() {
  639. // 毛重grossweight皮重tareweight入库重量operateweight
  640. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  641. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight)
  642. }
  643. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  644. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  645. this.create.createTemp.grossweight = this.create.createTemp.operateweight
  646. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight)
  647. }
  648. }
  649. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  650. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  651. this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
  652. } else {
  653. this.create.createTemp.sumprice = ''
  654. }
  655. },
  656. // 皮重
  657. blurTareweight() {
  658. // 毛重grossweight皮重tareweight入库重量operateweight
  659. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.tareweight !== '') {
  660. this.create.createTemp.grossweight = parseFloat(this.create.createTemp.tareweight) + parseFloat(this.create.createTemp.operateweight)
  661. }
  662. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  663. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  664. this.create.createTemp.grossweight = this.create.createTemp.operateweight
  665. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight)
  666. }
  667. }
  668. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  669. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  670. this.create.createTemp.tareweight = this.create.createTemp.grossweight
  671. this.create.createTemp.operateweight = (parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight))
  672. } else {
  673. this.create.createTemp.operateweight = (parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight))
  674. }
  675. }
  676. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  677. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  678. this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
  679. } else {
  680. this.create.createTemp.sumprice = ''
  681. }
  682. },
  683. // 单价
  684. blurPricenew() {
  685. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  686. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  687. this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
  688. } else {
  689. this.create.createTemp.sumprice = ''
  690. }
  691. },
  692. // 总价
  693. blurSumprice() {
  694. if (this.create.createTemp.sumprice !== '' && this.create.createTemp.pricenew !== '') {
  695. this.create.createTemp.operateweight = parseFloat(this.create.createTemp.sumprice) / parseFloat(this.create.createTemp.pricenew)
  696. this.create.createTemp.operateweight = this.create.createTemp.operateweight.toFixed(2)
  697. } else {
  698. this.create.createTemp.operateweight = ''
  699. }
  700. },
  701. handleCreate() {
  702. console.log('点击了新增入库单')
  703. this.create.dialogStatus = 'create'
  704. this.create.dialogFormVisible = true
  705. this.$nextTick(() => {
  706. this.resetCreateTemp()
  707. this.$refs.createTemp.resetFields()
  708. })
  709. },
  710. createData() {
  711. this.$refs['createTemp'].validate(valid => {
  712. if (valid) {
  713. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  714. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  715. return false
  716. }
  717. if (this.create.createTemp.sumprice.length > 15) {
  718. this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
  719. }
  720. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  721. // 入库重量
  722. if (this.create.createTemp.operateweight !== '') {
  723. if (this.create.createTemp.operateweight == 0) {
  724. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  725. return false
  726. } else {
  727. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  728. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  729. return false
  730. }
  731. }
  732. }
  733. // 单价
  734. if (this.create.createTemp.pricenew == 0) {
  735. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  736. return false
  737. } else {
  738. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  739. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  740. return false
  741. }
  742. }
  743. // 总价
  744. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  745. if (this.create.createTemp.sumprice == 0) {
  746. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  747. return false
  748. } else {
  749. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  750. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  751. return false
  752. }
  753. }
  754. }
  755. // 毛重
  756. if (this.create.createTemp.grossweight !== '') {
  757. if (this.create.createTemp.grossweight == 0) {
  758. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  759. return false
  760. } else {
  761. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  762. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  763. return false
  764. }
  765. }
  766. }
  767. // 皮重
  768. if (this.create.createTemp.tareweight !== '') {
  769. if (this.create.createTemp.tareweight == 0) {
  770. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  771. return false
  772. } else {
  773. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  774. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  775. return false
  776. }
  777. }
  778. }
  779. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  780. }).then(() => {
  781. this.isokDisable = true
  782. setTimeout(() => {
  783. this.isokDisable = false
  784. }, 1000)
  785. this.requestParam.common = { 'returnmap': '0' }
  786. this.requestParam.data = []
  787. this.requestParam.data[0] = { 'name': 'insertFeedlaid', 'type': 'e', 'parammaps': {
  788. 'pastureid': this.create.createTemp.pastureid,
  789. 'laiddate': this.create.createTemp.laiddate,
  790. 'feedid': this.create.createTemp.feedid,
  791. 'feedname': this.create.createTemp.feedname,
  792. 'providerid': this.create.createTemp.providerid,
  793. 'providername': this.create.createTemp.providername,
  794. 'contractcode': this.create.createTemp.contractcode,
  795. 'operateweight': this.create.createTemp.operateweight,
  796. 'grossweight': this.create.createTemp.grossweight,
  797. 'tareweight': this.create.createTemp.tareweight,
  798. 'sumprice': this.create.createTemp.sumprice,
  799. 'licence': this.create.createTemp.licence,
  800. 'pcpde': this.create.createTemp.pcpde,
  801. 'remark': this.create.createTemp.remark,
  802. 'createdate': this.create.createTemp.createdate,
  803. 'createemp': this.create.createTemp.createemp,
  804. 'startweight': this.create.createTemp.startweight,
  805. 'priceold': this.create.createTemp.priceold,
  806. 'pricenew': this.create.createTemp.pricenew,
  807. 'wagonnumber': this.create.createTemp.wagonnumber
  808. }}
  809. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  810. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  811. 'operateweight': this.create.createTemp.operateweight,
  812. 'pastureid': this.create.createTemp.pastureid,
  813. 'feedid': this.create.createTemp.feedid,
  814. 'fname': this.create.createTemp.fname,
  815. 'pcpde': this.create.createTemp.pcpde,
  816. 'stockweight': this.create.createTemp.startweight,
  817. 'price': this.create.createTemp.pricenew
  818. }}
  819. }
  820. console.log('点击了新增入库单保存', this.requestParam)
  821. ExecDataByConfig(this.requestParam).then(response => {
  822. if (response.msg === 'fail') {
  823. failproccess(response, this.$notify)
  824. } else {
  825. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  826. this.create.dialogFormVisible = false
  827. this.getList()
  828. }
  829. })
  830. })
  831. }
  832. })
  833. },
  834. handleUpdate(row) {
  835. console.log('点击了编辑')
  836. this.$nextTick(() => {
  837. this.$refs.createTemp.resetFields()
  838. })
  839. this.create.dialogStatus = 'update'
  840. this.create.dialogFormVisible = true
  841. row.feedid = String(row.feedid)
  842. if (row.providerid == -1) {
  843. row.providerid = ''
  844. row.providername = ''
  845. }
  846. this.create.createTemp = Object.assign({}, row)
  847. },
  848. updateData() {
  849. this.$refs['createTemp'].validate(valid => {
  850. if (valid) {
  851. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  852. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  853. return false
  854. }
  855. if (this.create.createTemp.sumprice.length > 15) {
  856. this.$message({ type: 'error', message: '数值过大请重新输入', duration: 2000 })
  857. }
  858. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  859. // 入库重量
  860. if (this.create.createTemp.operateweight !== '') {
  861. if (this.create.createTemp.operateweight == 0) {
  862. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  863. return false
  864. } else {
  865. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  866. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  867. return false
  868. }
  869. }
  870. }
  871. // 单价
  872. if (this.create.createTemp.pricenew == 0) {
  873. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  874. return false
  875. } else {
  876. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  877. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  878. return false
  879. }
  880. }
  881. // 总价
  882. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  883. if (this.create.createTemp.sumprice == 0) {
  884. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  885. return false
  886. } else {
  887. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  888. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  889. return false
  890. }
  891. }
  892. }
  893. // 毛重
  894. if (this.create.createTemp.grossweight !== '') {
  895. if (this.create.createTemp.grossweight == 0) {
  896. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  897. return false
  898. } else {
  899. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  900. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  901. return false
  902. }
  903. }
  904. }
  905. // 皮重
  906. if (this.create.createTemp.tareweight !== '') {
  907. if (this.create.createTemp.tareweight == 0) {
  908. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  909. return false
  910. } else {
  911. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  912. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  913. return false
  914. }
  915. }
  916. }
  917. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  918. }).then(() => {
  919. this.isokDisable = true
  920. setTimeout(() => {
  921. this.isokDisable = false
  922. }, 1000)
  923. this.requestParam.common = { 'returnmap': '0' }
  924. this.requestParam.data = []
  925. this.requestParam.data[0] = { 'name': 'updateFeedlaid', 'type': 'e', 'parammaps': {
  926. 'pastureid': this.create.createTemp.pastureid,
  927. 'id': this.create.createTemp.id,
  928. 'laiddate': this.create.createTemp.laiddate,
  929. 'feedid': this.create.createTemp.feedid,
  930. 'feedname': this.create.createTemp.feedname,
  931. 'providerid': this.create.createTemp.providerid,
  932. 'providername': this.create.createTemp.providername,
  933. 'contractcode': this.create.createTemp.contractcode,
  934. 'operateweight': this.create.createTemp.operateweight,
  935. 'grossweight': this.create.createTemp.grossweight,
  936. 'tareweight': this.create.createTemp.tareweight,
  937. 'sumprice': this.create.createTemp.sumprice,
  938. 'licence': this.create.createTemp.licence,
  939. 'pcpde': this.create.createTemp.pcpde,
  940. 'remark': this.create.createTemp.remark,
  941. 'createdate': this.create.createTemp.createdate,
  942. 'createemp': this.create.createTemp.createemp,
  943. 'startweight': this.create.createTemp.startweight,
  944. 'priceold': this.create.createTemp.priceold,
  945. 'pricenew': this.create.createTemp.pricenew,
  946. 'wagonnumber': this.create.createTemp.wagonnumber
  947. }}
  948. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  949. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  950. 'operateweight': this.create.createTemp.operateweight,
  951. 'pastureid': this.create.createTemp.pastureid,
  952. 'feedid': this.create.createTemp.feedid,
  953. 'fname': this.create.createTemp.fname,
  954. 'pcpde': this.create.createTemp.pcpde,
  955. 'stockweight': this.create.createTemp.startweight,
  956. 'price': this.create.createTemp.pricenew
  957. }}
  958. }
  959. console.log('点击了新增入库单保存', this.requestParam)
  960. ExecDataByConfig(this.requestParam).then(response => {
  961. if (response.msg === 'fail') {
  962. failproccess(response, this.$notify)
  963. } else {
  964. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  965. this.create.dialogFormVisible = false
  966. this.getList()
  967. }
  968. })
  969. })
  970. }
  971. })
  972. },
  973. handleSee(row) {
  974. console.log('点击了查看')
  975. this.$nextTick(() => {
  976. this.$refs.createTemp.resetFields()
  977. })
  978. this.create.dialogStatus = 'see'
  979. this.create.dialogFormVisible = true
  980. if (row.providerid == -1) {
  981. row.providerid = ''
  982. row.providername = ''
  983. }
  984. this.create.createTemp = Object.assign({}, row)
  985. },
  986. handleInitial() {
  987. console.log('点击了初始化库存')
  988. this.initial.dialogStatus = 'initial'
  989. this.initial.dialogFormVisible = true
  990. this.getInitialList()
  991. },
  992. getInitialList() {
  993. this.initial.listLoading = true
  994. GetDataByName(this.initial.getdataListParm).then(response => {
  995. console.log('table数据', response.data.list)
  996. if (response.data.list !== null) {
  997. this.initial.list = response.data.list
  998. this.initial.pageNum = response.data.pageNum
  999. this.initial.pageSize = response.data.pageSize
  1000. this.initial.total = response.data.total
  1001. } else {
  1002. this.initial.list = []
  1003. }
  1004. setTimeout(() => {
  1005. this.initial.listLoading = false
  1006. }, 100)
  1007. })
  1008. },
  1009. handleInitialExport() {
  1010. console.log('点击了初始化库存导出')
  1011. const ExcelDatas = [
  1012. {
  1013. tHeader: ['饲料名称', '库存重量'],
  1014. filterVal: ['fname', 'stockweight'],
  1015. tableDatas: this.initial.list,
  1016. sheetName: '初始化库存'
  1017. }
  1018. ]
  1019. json2excel(ExcelDatas, '初始化库存', true, 'xlsx')
  1020. },
  1021. async handleInitialImport(eve) {
  1022. const file = eve.raw
  1023. if (!file) return
  1024. let reader = await upload(file)
  1025. const worker = xlsx.read(reader, { type: 'binary' })
  1026. // 将返回的数据转换为json对象的数据
  1027. reader = xlsx.utils.sheet_to_json(worker.Sheets[worker.SheetNames[0]])
  1028. console.log(reader)
  1029. const arr = []
  1030. reader.forEach(item => {
  1031. const obj = {}
  1032. for (const key in this.initial.character) {
  1033. if (!this.initial.character.hasOwnProperty(key)) break
  1034. let v = this.initial.character[key]
  1035. const text = v.text
  1036. const type = v.type
  1037. v = item[text] || ''
  1038. type === 'string' ? (v = String(v)) : null
  1039. type === 'number' ? (v = Number(v)) : null
  1040. obj[key] = v
  1041. }
  1042. arr.push(obj)
  1043. })
  1044. console.log('导入处理后数据', arr)
  1045. var sum = 0
  1046. for (let i = 0; i < this.initial.list.length; i++) {
  1047. for (let j = 0; j < arr.length; j++) {
  1048. if (this.initial.list[i].fname == arr[j].fname) {
  1049. this.initial.list[i].stockweight = arr[j].stockweight
  1050. sum++
  1051. arr.splice(j, 1)
  1052. }
  1053. }
  1054. }
  1055. console.log(arr)
  1056. for (let i = 0; i < arr.length; i++) {
  1057. this.$set(arr[i], 'msg', '饲料名称与系统不匹配')
  1058. }
  1059. console.log(sum)
  1060. this.$message({ title: '成功', message: '导入成功:' + sum + '条!', type: 'success', duration: 2000 })
  1061. this.$notify({ title: '失败', message: '导入失败:' + arr.length + '条!', type: 'danger', duration: 2000 })
  1062. if (arr.length > 0) {
  1063. const ExcelDatas1 = [
  1064. {
  1065. tHeader: ['饲料名称', '库存重量', '报错信息'],
  1066. filterVal: ['fname', 'stockweight', 'msg'],
  1067. tableDatas: arr,
  1068. sheetName: 'ExcelDatas1'
  1069. }
  1070. ]
  1071. json2excel(ExcelDatas1, '初始化库存报错信息', true, 'xlsx')
  1072. }
  1073. },
  1074. initialData() {
  1075. console.log('点击了初始化库存保存')
  1076. this.isokDisable = true
  1077. setTimeout(() => {
  1078. this.isokDisable = false
  1079. }, 1000)
  1080. var rulesStockweight = /^\d+(\.\d{1,2})?$/
  1081. for (let i = 0; i < this.initial.list.length; i++) {
  1082. if (!rulesStockweight.test(parseFloat(this.initial.list[i].stockweight))) {
  1083. this.$message({ type: 'warning', message: '库存重量不可小于0,且保留俩位小数', duration: 2000 })
  1084. return false
  1085. }
  1086. }
  1087. this.requestParam.common = { 'returnmap': '0' }
  1088. this.requestParam.data = []
  1089. this.requestParam.data[0] = { 'name': 'clearFS', 'type': 'e', 'parammaps': {
  1090. 'pastureid': Cookies.get('pastureid')
  1091. }}
  1092. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.initial.list }}
  1093. this.requestParam.data[1].children = []
  1094. this.requestParam.data[1].children[0] = { 'name': 'insertFeedstorage', 'type': 'e', 'parammaps': {
  1095. pastureid: '@insertSpotList.pastureid',
  1096. feedid: '@insertSpotList.feedid',
  1097. fname: '@insertSpotList.fname',
  1098. pcpde: '@insertSpotList.pcpde',
  1099. stockweight: '@insertSpotList.stockweight',
  1100. price: '@insertSpotList.price'
  1101. }}
  1102. ExecDataByConfig(this.requestParam).then(response => {
  1103. if (response.msg === 'fail') {
  1104. failproccess(response, this.$notify)
  1105. } else {
  1106. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  1107. this.create.dialogFormVisible = false
  1108. this.getList()
  1109. }
  1110. })
  1111. },
  1112. // 导出
  1113. handleExport(item) {
  1114. if (item == 1) {
  1115. console.log('点击了导出模板')
  1116. } else {
  1117. console.log('点击了导出数据')
  1118. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1119. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  1120. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  1121. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  1122. } else {
  1123. this.download.getdataListParm.parammaps.inputDatetime = ''
  1124. this.download.getdataListParm.parammaps.startTime = ''
  1125. this.download.getdataListParm.parammaps.stopTime = ''
  1126. }
  1127. GetDataByName(this.download.getdataListParm).then(response => {
  1128. if (response.data.list !== null) {
  1129. this.download.list = response.data.list
  1130. } else {
  1131. this.download.list = []
  1132. }
  1133. var excelDatas = [
  1134. {
  1135. tHeader: ['入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注'],
  1136. filterVal: ['laiddate', 'wagonnumber', 'feedname', 'providername', 'contractcode', 'operateweight', 'pricenew', 'sumprice', 'grossweight', 'tareweight', 'licence', 'pcpde', 'createemp', 'createdate', 'remark'],
  1137. tableDatas: this.download.list,
  1138. sheetName: 'Sheet1'
  1139. }
  1140. ]
  1141. json2excel(excelDatas, '入库管理', true, 'xlsx')
  1142. })
  1143. }
  1144. },
  1145. beforeImport(file) {
  1146. const isLt2M = file.size / 1024 / 1024 < 2
  1147. if (!isLt2M) {
  1148. this.$message.error('上传文件大小不能超过 2MB!')
  1149. }
  1150. return isLt2M
  1151. },
  1152. handleImportSuccess(res, file) {
  1153. this.getList()
  1154. if (res.msg === 'ok') {
  1155. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1156. if (res.data.err_count > 0) {
  1157. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1158. import('@/vendor/Export2Excel').then(excel => {
  1159. const list1 = res.data.result
  1160. const tHeader = [
  1161. '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', '错误信息'
  1162. ]
  1163. const filterVal = [
  1164. '入库日期', '送货单编号', '饲料名称', '供应商', '合同编号', '入库重量(kg)', '单价(元)', '总价(元)', '毛重(kg)', '皮重(kg)', '许可证号', '批号', '创建人', '创建日期', '备注', 'error_msg'
  1165. ]
  1166. const data1 = this.formatJson(filterVal, list1)
  1167. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '入库管理导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1168. })
  1169. }
  1170. } else {
  1171. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1172. }
  1173. },
  1174. formatJson(filterVal, jsonData) {
  1175. return jsonData.map(v =>
  1176. filterVal.map(j => {
  1177. if (j === 'timestamp') {
  1178. return parseTime(v[j])
  1179. } else {
  1180. return v[j]
  1181. }
  1182. })
  1183. )
  1184. }
  1185. }
  1186. }
  1187. </script>
  1188. <style lang="scss" scoped>
  1189. .search{margin-top:10px;}
  1190. .table{margin-top:10px;}
  1191. </style>