a5b946e3e9b38e0bf89389e70eaed0c48b5f4832.svn-base 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  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. </div>
  7. <div class="search">
  8. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  9. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  10. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  11. <el-select v-model="table.getdataListParm.parammaps.feedid" placeholder="饲料名称" class="filter-item" style="width: 150px;" clearable>
  12. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  13. </el-select>
  14. <el-select v-model="table.getdataListParm.parammaps.providerid" placeholder="供应商" class="filter-item" style="width: 150px;" clearable>
  15. <el-option v-for="item in supplierList" :key="item.id" :label="item.providerName" :value="item.id" />
  16. </el-select>
  17. <el-select v-model="table.getdataListParm.parammaps.islaid" placeholder="是否入库" class="filter-item" style="width: 150px;" clearable>
  18. <el-option v-for="item in islaidList" :key="item.id" :label="item.name" :value="item.name" />
  19. </el-select>
  20. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  21. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  22. </div>
  23. <div class="table">
  24. <el-table
  25. :key="table.tableKey"
  26. v-loading="table.listLoading"
  27. element-loading-text="给我一点时间"
  28. :data="table.list"
  29. border
  30. fit
  31. highlight-current-row
  32. style="width: 100%;"
  33. :row-style="rowStyle"
  34. :cell-style="cellStyle"
  35. class="elTable table-fixed"
  36. >
  37. <el-table-column label="序号" align="center" type="index" width="50px">
  38. <template slot-scope="scope">
  39. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="入库日期" min-width="130px" align="center">
  43. <template slot-scope="scope">
  44. <span>{{ scope.row.laiddate }}</span>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="饲料名称" min-width="130px" align="center">
  48. <template slot-scope="scope">
  49. <span>{{ scope.row.feedname }}</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.providername }}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="入库重量(kg)" min-width="110px" align="center">
  58. <template slot-scope="scope">
  59. <span>{{ scope.row.operateweight }}</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="总价(元)" min-width="110px" align="center">
  63. <template slot-scope="scope">
  64. <span>{{ scope.row.sumprice }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="批号" min-width="110px" align="center">
  68. <template slot-scope="scope">
  69. <span>{{ scope.row.pcpde }}</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.remark }}</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.islaid }}</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.createemp }}</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.createdate }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  93. <template slot-scope="{row}">
  94. <el-button class="miniPrimary" @click="handleSee(row)">查看</el-button>
  95. <el-button v-if="row.islaid == '否'" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  100. </div>
  101. <!-- 新增入库单 -->
  102. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  103. <div class="app-add">
  104. <el-form ref="createTemp" :rules="create.rules" :model="create.createTemp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto 50px">
  105. <el-row>
  106. <el-col :span="24">
  107. <h3 style="width: 160px;text-align: right;">基础信息</h3>
  108. </el-col>
  109. </el-row>
  110. <el-row>
  111. <el-col :span="8">
  112. <el-form-item label="入库日期:" prop="laiddate">
  113. <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" />
  114. </el-form-item>
  115. </el-col>
  116. <el-col :span="8">
  117. <el-form-item label="送货单编号:" prop="wagonnumber">
  118. <el-input ref="wagonnumber" v-model="create.createTemp.wagonnumber" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="送货单编号" type="text" />
  119. </el-form-item>
  120. </el-col>
  121. <el-col :span="8">
  122. <el-form-item label="饲料名称:" prop="feedname">
  123. <el-autocomplete
  124. v-model="create.createTemp.feedname"
  125. value-key="fname"
  126. class="inline-input"
  127. :fetch-suggestions="feedNameSearch"
  128. placeholder="请选择饲料名称"
  129. style="width:98%"
  130. :disabled="create.dialogStatus=='see' || create.dialogStatus=='update'"
  131. @select="handleSelectFeedName"
  132. @blur="blurFeedName"
  133. >
  134. <template slot-scope="{ item }">
  135. <span>{{ item.fname }}</span>
  136. </template>
  137. </el-autocomplete>
  138. </el-form-item>
  139. </el-col>
  140. </el-row>
  141. <el-row>
  142. <el-col :span="8">
  143. <el-form-item label="入库重量(kg):" prop="operateweight">
  144. <el-input ref="operateweight" v-model="create.createTemp.operateweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurOperateweight" />
  145. </el-form-item>
  146. </el-col>
  147. <el-col :span="8">
  148. <el-form-item label="供应商:" prop="providerid">
  149. <el-select v-model="create.createTemp.providerid" placeholder="请选择供应商" :disabled="create.dialogStatus=='see'" class="filter-item" style="width: 100%" @change="changeSupplier">
  150. <el-option v-for="item in supplierList" :key="item.id" :label="item.providerName" :value="item.id" />
  151. </el-select>
  152. </el-form-item>
  153. </el-col>
  154. <el-col :span="8">
  155. <el-form-item label="合同编号:" prop="contractcode">
  156. <el-select v-model="create.createTemp.contractcode" placeholder="请选择合同编号" :disabled="create.dialogStatus=='see'" class="filter-item" style="width: 100%" @change="changeContractNo">
  157. <el-option v-for="item in contractNoList" :key="item.id" :label="item.contractcodeCat" :value="item.contractcode" />
  158. </el-select>
  159. </el-form-item>
  160. </el-col>
  161. </el-row>
  162. <el-row>
  163. <el-col :span="24">
  164. <h3 style="width: 160px;text-align: right;">价格信息</h3>
  165. </el-col>
  166. </el-row>
  167. <el-row>
  168. <el-col :span="8">
  169. <el-form-item label="单价(元):" prop="pricenew">
  170. <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" />
  171. </el-form-item>
  172. </el-col>
  173. <el-col :span="8">
  174. <el-form-item label="总价(元):" prop="sumprice">
  175. <el-input ref="sumprice" v-model="create.createTemp.sumprice" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurSumprice" />
  176. </el-form-item>
  177. </el-col>
  178. </el-row>
  179. <el-row>
  180. <el-col :span="24">
  181. <h3 style="width: 160px;text-align: right;">饲料信息</h3>
  182. </el-col>
  183. </el-row>
  184. <el-row>
  185. <el-col :span="8">
  186. <el-form-item label="毛重:" prop="grossweight">
  187. <el-input ref="grossweight" v-model="create.createTemp.grossweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurGrossweight" />
  188. </el-form-item>
  189. </el-col>
  190. <el-col :span="8">
  191. <el-form-item label="皮重:" prop="tareweight">
  192. <el-input ref="tareweight" v-model="create.createTemp.tareweight" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="最多两位小数" type="number" :step="0.01" @blur="blurTareweight" />
  193. </el-form-item>
  194. </el-col>
  195. <el-col :span="8">
  196. <el-form-item label="许可证号:" prop="licence">
  197. <el-input ref="licence" v-model="create.createTemp.licence" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="许可证号" type="text" />
  198. </el-form-item>
  199. </el-col>
  200. </el-row>
  201. <el-row>
  202. <el-col :span="8">
  203. <el-form-item label="批号:" prop="pcpde">
  204. <el-input ref="pcpde" v-model="create.createTemp.pcpde" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="批号" type="text" />
  205. </el-form-item>
  206. </el-col>
  207. </el-row>
  208. <el-row>
  209. <el-col :span="24">
  210. <h3 style="width: 160px;text-align: right;">操作信息</h3>
  211. </el-col>
  212. </el-row>
  213. <el-row>
  214. <el-col :span="8">
  215. <el-form-item label="创建人:" prop="createemp">
  216. <el-input ref="createemp" v-model="create.createTemp.createemp" class="filter-item" placeholder="创建人" type="text" disabled />
  217. </el-form-item>
  218. </el-col>
  219. <el-col :span="8">
  220. <el-form-item label="创建日期:" prop="createdate">
  221. <el-date-picker v-model="create.createTemp.createdate" class="filter-item" type="date" placeholder="创建日期" disabled />
  222. </el-form-item>
  223. </el-col>
  224. <el-col :span="8">
  225. <el-form-item label="备注:" prop="remark">
  226. <el-input ref="remark" v-model="create.createTemp.remark" :disabled="create.dialogStatus=='see'" class="filter-item" placeholder="1-255字符" type="text" />
  227. </el-form-item>
  228. </el-col>
  229. </el-row>
  230. </el-form>
  231. <div slot="footer" class="dialog-footer">
  232. <el-button class="cancel" @click="create.dialogFormVisible = false;getList(); ">关闭</el-button>
  233. <el-button v-if="create.dialogStatus !== 'see' " class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  234. </div>
  235. </div>
  236. </el-dialog>
  237. <!-- 初始化库存 -->
  238. <el-dialog :title="textMap[initial.dialogStatus]" :visible.sync="initial.dialogFormVisible" :close-on-click-modal="false" width="80%" height="55%">
  239. <div class="app-add" style="height: 100%;margin: 0 auto 60px;">
  240. <div class="operation">
  241. <el-button style="float: left;margin-bottom:10px;" class="success" @click="handleInitialExport">模板下载</el-button>
  242. <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">
  243. <el-button class="success">导入</el-button>
  244. </el-upload>
  245. </div>
  246. <div class="table">
  247. <el-table
  248. :key="initial.tableKey"
  249. v-loading="initial.listLoading"
  250. element-loading-text="给我一点时间"
  251. :data="initial.list"
  252. border
  253. fit
  254. highlight-current-row
  255. style="width: 100%;"
  256. :row-style="rowStyle"
  257. :cell-style="cellStyle"
  258. class="elTable table-fixed"
  259. >
  260. <el-table-column label="序号" align="center" type="index" width="50px" />
  261. <el-table-column label="饲料名称" min-width="130px" align="center">
  262. <template slot-scope="scope">
  263. <span>{{ scope.row.fname }}</span>
  264. </template>
  265. </el-table-column>
  266. <el-table-column label="库存重量" min-width="130px" align="center">
  267. <template slot-scope="scope">
  268. <el-input v-model="scope.row.stockweight" placeholder="最多两位小数" type="number" :step="0.01" style="width:95%;padding:10px 0;" />
  269. </template>
  270. </el-table-column>
  271. </el-table>
  272. <div slot="footer" class="dialog-footer">
  273. <el-button class="cancel" @click="initial.dialogFormVisible = false; ">关闭</el-button>
  274. <el-button class="success" :disabled="isokDisable" @click="initialData()">确认</el-button>
  275. </div>
  276. </div>
  277. </div></el-dialog>
  278. </div>
  279. </template>
  280. <script>
  281. import { GetDataByName, GetDataByNames, checkButtons, ExecDataByConfig, failproccess } from '@/api/common'
  282. import Pagination from '@/components/Pagination'
  283. import { MessageBox } from 'element-ui'
  284. import Cookies from 'js-cookie'
  285. import { json2excel, parseTime } from '@/utils/index.js'
  286. // import { getToken } from '@/utils/auth'
  287. import xlsx from 'xlsx'
  288. import { upload } from '@/utils/index.js'
  289. export default {
  290. name: 'Warehousing',
  291. components: { Pagination },
  292. data() {
  293. return {
  294. feedNameList: [], // 饲料名称
  295. feedNameAddList: [], // 饲料名称新增
  296. supplierList: [], // 供应商
  297. contractNoList: [], // 合同编号
  298. islaidList: [{ id: 0, name: '是' }, { id: 1, name: '否' }], // 是否入库
  299. requestParams: [
  300. { name: 'getFeedListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  301. { name: 'getProviderListEnable', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  302. ],
  303. table: {
  304. getdataListParm: {
  305. name: 'getFeedlaidList',
  306. page: 1,
  307. offset: 1,
  308. pagecount: 10,
  309. returntype: 'Map',
  310. parammaps: {
  311. pastureid: Cookies.get('pastureid'),
  312. inputDatetime: '',
  313. startTime: '',
  314. stopTime: '',
  315. feedid: '',
  316. islaid: '',
  317. providerid: ''
  318. }
  319. },
  320. tableKey: 0,
  321. list: [],
  322. total: 0,
  323. listLoading: true
  324. },
  325. create: {
  326. dialogFormVisible: false,
  327. dialogStatus: '',
  328. pickerOptions1: {
  329. disabledDate(time) {
  330. return time.getTime() > Date.now()// 当天之前的时间可选
  331. }
  332. },
  333. createTemp: {
  334. laiddate: '', feedid: '', feedname: '', operateweight: '', providerid: '', providername: '', startweight: '', priceold: '', contractcode: '', pricenew: '', sumprice: '', grossweight: '', tareweight: '', licence: '', pcpde: '', createemp: '', createdate: '', remark: '', 'wagonnumber': ''
  335. },
  336. rules: {
  337. laiddate: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  338. feedname: [{ type: 'string', required: true, message: '必填', trigger: 'change' }],
  339. pricenew: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  340. },
  341. getdataListParm: {
  342. name: 'getBigContractListEnable',
  343. offset: 0,
  344. pagecount: '',
  345. parammaps: { pastureid: Cookies.get('pastureid') }
  346. },
  347. getfeedNameParm: {
  348. name: 'getFeedListEnableV2',
  349. offset: 0,
  350. pagecount: '',
  351. parammaps: { pastureid: Cookies.get('pastureid') }
  352. }
  353. },
  354. initial: {
  355. dialogFormVisible: false,
  356. dialogStatus: '',
  357. rules: {},
  358. getdataListParm: {
  359. name: 'getinitFeed',
  360. page: 1,
  361. offset: 1,
  362. pagecount: 6,
  363. returntype: 'Map',
  364. parammaps: {
  365. pastureid: Cookies.get('pastureid')
  366. }
  367. },
  368. tableKey: 0,
  369. list: [],
  370. total: 0,
  371. listLoading: true,
  372. character: {
  373. fname: {
  374. text: '饲料名称',
  375. type: String
  376. },
  377. stockweight: {
  378. text: '库存重量',
  379. type: String
  380. }
  381. }
  382. },
  383. textMap: {
  384. create: '新增入库单',
  385. update: '编辑入库单',
  386. see: '查看入库单',
  387. initial: '初始化库存'
  388. },
  389. requestParam: {},
  390. isokDisable: false,
  391. isRoleEdit: [],
  392. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  393. cellStyle: { padding: 0 + 'px' }
  394. }
  395. },
  396. created() {
  397. this.getButtons()
  398. this.getDownList()
  399. this.getList()
  400. },
  401. methods: {
  402. getButtons() {
  403. const Edit = 'Warehousing'
  404. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  405. this.isRoleEdit = isRoleEdit
  406. },
  407. getDownList() {
  408. GetDataByNames(this.requestParams).then(response => {
  409. this.feedNameList = response.data.getFeedListEnable.list
  410. this.supplierList = response.data.getProviderListEnable.list
  411. })
  412. },
  413. handleBefore() {
  414. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  415. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  416. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  417. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  418. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  419. this.$forceUpdate()
  420. }
  421. },
  422. handleNext() {
  423. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  424. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  425. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  426. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  427. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  428. this.$forceUpdate()
  429. }
  430. },
  431. getList() {
  432. this.table.listLoading = true
  433. GetDataByName(this.table.getdataListParm).then(response => {
  434. console.log('table数据', response.data.list)
  435. if (response.data.list !== null) {
  436. this.table.list = response.data.list
  437. this.table.pageNum = response.data.pageNum
  438. this.table.pageSize = response.data.pageSize
  439. this.table.total = response.data.total
  440. } else {
  441. this.table.list = []
  442. }
  443. setTimeout(() => {
  444. this.table.listLoading = false
  445. }, 100)
  446. })
  447. },
  448. handleSearch() {
  449. console.log('点击了查询')
  450. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  451. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  452. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  453. } else {
  454. this.table.getdataListParm.parammaps.inputDatetime = ''
  455. this.table.getdataListParm.parammaps.startTime = ''
  456. this.table.getdataListParm.parammaps.stopTime = ''
  457. }
  458. this.table.getdataListParm.offset = 1
  459. this.getList()
  460. },
  461. handleRefresh() {
  462. console.log('点击了重置')
  463. this.table.getdataListParm.parammaps.inputDatetime = ''
  464. this.table.getdataListParm.parammaps.startTime = ''
  465. this.table.getdataListParm.parammaps.stopTime = ''
  466. this.table.getdataListParm.parammaps.feedid = ''
  467. this.table.getdataListParm.parammaps.islaid = ''
  468. this.table.getdataListParm.parammaps.providerid = ''
  469. this.table.getdataListParm.offset = 1
  470. },
  471. resetCreateTemp() {
  472. this.create.createTemp = {
  473. 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': ''
  474. }
  475. this.contractNoList = []
  476. },
  477. // 供应商
  478. changeSupplier(item) {
  479. this.create.createTemp.providername = this.supplierList.find(obj => obj.id == item).providerName
  480. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  481. this.getContractNoList()
  482. }
  483. },
  484. // 合同编号
  485. changeContractNo(item) {
  486. this.create.createTemp.pricenew = this.contractNoList.find(obj => obj.contractcode == item).price
  487. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  488. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  489. this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
  490. }
  491. },
  492. getContractNoList() {
  493. this.create.getdataListParm.parammaps.feedid = this.create.createTemp.feedid
  494. this.create.getdataListParm.parammaps.providerid = this.create.createTemp.providerid
  495. GetDataByName(this.create.getdataListParm).then(response => {
  496. console.log('table数据', response.data.list)
  497. if (response.data.list !== null) {
  498. this.contractNoList = response.data.list
  499. this.create.createTemp.contractcode = ''
  500. this.create.createTemp.pricenew = ''
  501. this.create.createTemp.sumprice = ''
  502. } else {
  503. this.contractNoList = []
  504. this.create.createTemp.contractcode = ''
  505. this.create.createTemp.pricenew = ''
  506. this.create.createTemp.sumprice = ''
  507. }
  508. })
  509. },
  510. feedNameSearch(queryString, cb) {
  511. this.create.getfeedNameParm.parammaps['fname'] = queryString
  512. GetDataByName(this.create.getfeedNameParm).then(response => {
  513. console.log('模糊查询搜索data', response.data.list)
  514. if (response.data.list == null) {
  515. cb([])
  516. } else {
  517. cb(response.data.list)
  518. }
  519. })
  520. },
  521. handleSelectFeedName(item) {
  522. console.log('模糊查询选中值', item)
  523. this.create.createTemp.feedname = item.fname
  524. this.create.createTemp.feedid = item.id
  525. this.create.createTemp.startweight = item.stockweight
  526. this.create.createTemp.priceold = item.price
  527. this.create.createTemp.providerid = ''
  528. this.create.createTemp.providername = ''
  529. this.create.createTemp.contractcode = ''
  530. this.create.createTemp.pricenew = ''
  531. this.create.createTemp.sumprice = ''
  532. if (this.create.createTemp.feedid !== '' && this.create.createTemp.providerid !== '') {
  533. this.getContractNoList()
  534. }
  535. },
  536. blurFeedName() {
  537. this.create.createTemp.feedname = ''
  538. this.create.createTemp.feedid = ''
  539. this.create.createTemp.startweight = ''
  540. this.create.createTemp.priceold = ''
  541. this.create.createTemp.providerid = ''
  542. this.create.createTemp.providername = ''
  543. this.create.createTemp.contractcode = ''
  544. this.create.createTemp.pricenew = ''
  545. this.create.createTemp.sumprice = ''
  546. },
  547. // 入库重量
  548. blurOperateweight() {
  549. // 毛重grossweight皮重tareweight入库重量operateweight
  550. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  551. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight)
  552. }
  553. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  554. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  555. this.create.createTemp.grossweight = this.create.createTemp.operateweight
  556. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight)
  557. }
  558. }
  559. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  560. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  561. this.create.createTemp.tareweight = this.create.createTemp.grossweight
  562. this.create.createTemp.grossweight = (parseFloat(this.create.createTemp.tareweight) + parseFloat(this.create.createTemp.operateweight)
  563. }
  564. }
  565. },
  566. // 毛重
  567. blurGrossweight() {
  568. // 毛重grossweight皮重tareweight入库重量operateweight
  569. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  570. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight)
  571. }
  572. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  573. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  574. this.create.createTemp.grossweight = this.create.createTemp.operateweight
  575. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight)
  576. }
  577. }
  578. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  579. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  580. this.create.createTemp.tareweight = this.create.createTemp.grossweight
  581. this.create.createTemp.grossweight = (parseFloat(this.create.createTemp.tareweight) + parseFloat(this.create.createTemp.operateweight)
  582. }
  583. }
  584. },
  585. // 皮重
  586. blurTareweight() {
  587. // 毛重grossweight皮重tareweight入库重量operateweight
  588. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.tareweight !== '') {
  589. this.create.createTemp.grossweight = parseFloat(this.create.createTemp.grossweight) + parseFloat(this.create.createTemp.operateweight)
  590. }
  591. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  592. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  593. this.create.createTemp.grossweight = this.create.createTemp.operateweight
  594. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.operateweight) - parseFloat(this.create.createTemp.operateweight)
  595. }
  596. }
  597. if (this.create.createTemp.tareweight !== '' && this.create.createTemp.grossweight !== '') {
  598. if (parseFloat(this.create.createTemp.tareweight) > parseFloat(this.create.createTemp.grossweight)) {
  599. this.create.createTemp.tareweight = this.create.createTemp.grossweight
  600. this.create.createTemp.grossweight = (parseFloat(this.create.createTemp.tareweight) + parseFloat(this.create.createTemp.operateweight)
  601. }
  602. }
  603. },
  604. // 单价
  605. blurPricenew() {
  606. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  607. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  608. this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
  609. } else {
  610. this.create.createTemp.sumprice = ''
  611. }
  612. },
  613. // 总价
  614. blurSumprice() {
  615. if (this.create.createTemp.sumprice !== '' && this.create.createTemp.pricenew !== '') {
  616. this.create.createTemp.operateweight = parseFloat(this.create.createTemp.sumprice) / parseFloat(this.create.createTemp.pricenew)
  617. this.create.createTemp.operateweight = this.create.createTemp.operateweight.toFixed(2)
  618. } else {
  619. this.create.createTemp.operateweight = ''
  620. }
  621. },
  622. handleCreate() {
  623. console.log('点击了新增入库单')
  624. this.resetCreateTemp()
  625. this.create.dialogStatus = 'create'
  626. this.create.dialogFormVisible = true
  627. },
  628. createData() {
  629. this.$refs['createTemp'].validate(valid => {
  630. if (valid) {
  631. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  632. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  633. return false
  634. }
  635. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  636. // 入库重量
  637. if (this.create.createTemp.operateweight == 0) {
  638. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  639. return false
  640. } else {
  641. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  642. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  643. return false
  644. }
  645. }
  646. // 单价
  647. if (this.create.createTemp.pricenew == 0) {
  648. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  649. return false
  650. } else {
  651. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  652. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  653. return false
  654. }
  655. }
  656. // 总价
  657. if (this.create.createTemp.sumprice == 0) {
  658. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  659. return false
  660. } else {
  661. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  662. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  663. return false
  664. }
  665. }
  666. // 毛重
  667. if (this.create.createTemp.grossweight == 0) {
  668. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  669. return false
  670. } else {
  671. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  672. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  673. return false
  674. }
  675. }
  676. // 皮重
  677. if (this.create.createTemp.tareweight == 0) {
  678. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  679. return false
  680. } else {
  681. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  682. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  683. return false
  684. }
  685. }
  686. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  687. }).then(() => {
  688. this.isokDisable = true
  689. setTimeout(() => {
  690. this.isokDisable = false
  691. }, 1000)
  692. this.requestParam.common = { 'returnmap': '0' }
  693. this.requestParam.data = []
  694. this.requestParam.data[0] = { 'name': 'insertFeedlaid', 'type': 'e', 'parammaps': {
  695. 'pastureid': this.create.createTemp.pastureid,
  696. 'laiddate': this.create.createTemp.laiddate,
  697. 'feedid': this.create.createTemp.feedid,
  698. 'feedname': this.create.createTemp.feedname,
  699. 'providerid': this.create.createTemp.providerid,
  700. 'providername': this.create.createTemp.providername,
  701. 'contractcode': this.create.createTemp.contractcode,
  702. 'operateweight': this.create.createTemp.operateweight,
  703. 'grossweight': this.create.createTemp.grossweight,
  704. 'tareweight': this.create.createTemp.tareweight,
  705. 'sumprice': this.create.createTemp.sumprice,
  706. 'licence': this.create.createTemp.licence,
  707. 'pcpde': this.create.createTemp.pcpde,
  708. 'remark': this.create.createTemp.remark,
  709. 'createdate': this.create.createTemp.createdate,
  710. 'createemp': this.create.createTemp.createemp,
  711. 'startweight': this.create.createTemp.startweight,
  712. 'priceold': this.create.createTemp.priceold,
  713. 'pricenew': this.create.createTemp.pricenew,
  714. 'wagonnumber': this.create.createTemp.wagonnumber
  715. }}
  716. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  717. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  718. 'operateweight': this.create.createTemp.operateweight,
  719. 'pastureid': this.create.createTemp.pastureid,
  720. 'feedid': this.create.createTemp.feedid,
  721. 'fname': this.create.createTemp.fname,
  722. 'pcpde': this.create.createTemp.pcpde,
  723. 'stockweight': this.create.createTemp.startweight,
  724. 'price': this.create.createTemp.pricenew
  725. }}
  726. }
  727. console.log('点击了新增入库单保存', this.requestParam)
  728. ExecDataByConfig(this.requestParam).then(response => {
  729. if (response.msg === 'fail') {
  730. failproccess(response, this.$notify)
  731. } else {
  732. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  733. this.create.dialogFormVisible = false
  734. this.getList()
  735. }
  736. })
  737. })
  738. }
  739. })
  740. },
  741. handleUpdate(row) {
  742. console.log('点击了编辑')
  743. this.create.dialogStatus = 'update'
  744. this.create.dialogFormVisible = true
  745. row.feedid = String(row.feedid)
  746. this.create.createTemp = Object.assign({}, row)
  747. },
  748. updateData() {
  749. this.$refs['createTemp'].validate(valid => {
  750. if (valid) {
  751. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  752. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  753. return false
  754. }
  755. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  756. }).then(() => {
  757. this.isokDisable = true
  758. setTimeout(() => {
  759. this.isokDisable = false
  760. }, 1000)
  761. this.requestParam.common = { 'returnmap': '0' }
  762. this.requestParam.data = []
  763. this.requestParam.data[0] = { 'name': 'updateFeedlaid', 'type': 'e', 'parammaps': {
  764. 'pastureid': this.create.createTemp.pastureid,
  765. 'id': this.create.createTemp.id,
  766. 'laiddate': this.create.createTemp.laiddate,
  767. 'feedid': this.create.createTemp.feedid,
  768. 'feedname': this.create.createTemp.feedname,
  769. 'providerid': this.create.createTemp.providerid,
  770. 'providername': this.create.createTemp.providername,
  771. 'contractcode': this.create.createTemp.contractcode,
  772. 'operateweight': this.create.createTemp.operateweight,
  773. 'grossweight': this.create.createTemp.grossweight,
  774. 'tareweight': this.create.createTemp.tareweight,
  775. 'sumprice': this.create.createTemp.sumprice,
  776. 'licence': this.create.createTemp.licence,
  777. 'pcpde': this.create.createTemp.pcpde,
  778. 'remark': this.create.createTemp.remark,
  779. 'createdate': this.create.createTemp.createdate,
  780. 'createemp': this.create.createTemp.createemp,
  781. 'startweight': this.create.createTemp.startweight,
  782. 'priceold': this.create.createTemp.priceold,
  783. 'pricenew': this.create.createTemp.pricenew,
  784. 'wagonnumber': this.create.createTemp.wagonnumber
  785. }}
  786. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  787. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  788. 'operateweight': this.create.createTemp.operateweight,
  789. 'pastureid': this.create.createTemp.pastureid,
  790. 'feedid': this.create.createTemp.feedid,
  791. 'fname': this.create.createTemp.fname,
  792. 'pcpde': this.create.createTemp.pcpde,
  793. 'stockweight': this.create.createTemp.startweight,
  794. 'price': this.create.createTemp.pricenew
  795. }}
  796. }
  797. console.log('点击了新增入库单保存', this.requestParam)
  798. ExecDataByConfig(this.requestParam).then(response => {
  799. if (response.msg === 'fail') {
  800. failproccess(response, this.$notify)
  801. } else {
  802. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  803. this.create.dialogFormVisible = false
  804. this.getList()
  805. }
  806. })
  807. })
  808. }
  809. })
  810. },
  811. handleSee(row) {
  812. console.log('点击了查看')
  813. this.create.dialogStatus = 'see'
  814. this.create.dialogFormVisible = true
  815. this.create.createTemp = Object.assign({}, row)
  816. },
  817. handleInitial() {
  818. console.log('点击了初始化库存')
  819. this.initial.dialogStatus = 'initial'
  820. this.initial.dialogFormVisible = true
  821. this.getInitialList()
  822. },
  823. getInitialList() {
  824. this.initial.listLoading = true
  825. GetDataByName(this.initial.getdataListParm).then(response => {
  826. console.log('table数据', response.data.list)
  827. if (response.data.list !== null) {
  828. this.initial.list = response.data.list
  829. this.initial.pageNum = response.data.pageNum
  830. this.initial.pageSize = response.data.pageSize
  831. this.initial.total = response.data.total
  832. } else {
  833. this.initial.list = []
  834. }
  835. setTimeout(() => {
  836. this.initial.listLoading = false
  837. }, 100)
  838. })
  839. },
  840. handleInitialExport() {
  841. console.log('点击了初始化库存导出')
  842. const ExcelDatas = [
  843. {
  844. tHeader: ['饲料名称', '库存重量'],
  845. filterVal: ['fname', 'stockweight'],
  846. tableDatas: this.initial.list,
  847. sheetName: '初始化库存'
  848. }
  849. ]
  850. json2excel(ExcelDatas, '初始化库存', true, 'xlsx')
  851. },
  852. async handleInitialImport(eve) {
  853. const file = eve.raw
  854. if (!file) return
  855. let reader = await upload(file)
  856. const worker = xlsx.read(reader, { type: 'binary' })
  857. // 将返回的数据转换为json对象的数据
  858. reader = xlsx.utils.sheet_to_json(worker.Sheets[worker.SheetNames[0]])
  859. console.log(reader)
  860. const arr = []
  861. reader.forEach(item => {
  862. const obj = {}
  863. for (const key in this.initial.character) {
  864. if (!this.initial.character.hasOwnProperty(key)) break
  865. let v = this.initial.character[key]
  866. const text = v.text
  867. const type = v.type
  868. v = item[text] || ''
  869. type === 'string' ? (v = String(v)) : null
  870. type === 'number' ? (v = Number(v)) : null
  871. obj[key] = v
  872. }
  873. arr.push(obj)
  874. })
  875. console.log('导入处理后数据', arr)
  876. var sum = 0
  877. for (let i = 0; i < this.initial.list.length; i++) {
  878. for (let j = 0; j < arr.length; j++) {
  879. if (this.initial.list[i].fname == arr[j].fname) {
  880. this.initial.list[i].stockweight = arr[j].stockweight
  881. sum++
  882. arr.splice(j, 1)
  883. }
  884. }
  885. }
  886. console.log(arr)
  887. for (let i = 0; i < arr.length; i++) {
  888. this.$set(arr[i], 'msg', '饲料名称与系统不匹配')
  889. }
  890. console.log(sum)
  891. this.$message({ title: '成功', message: '导入成功:' + sum + '条!', type: 'success', duration: 2000 })
  892. this.$notify({ title: '失败', message: '导入失败:' + arr.length + '条!', type: 'danger', duration: 2000 })
  893. if (arr.length > 0) {
  894. const ExcelDatas1 = [
  895. {
  896. tHeader: ['饲料名称', '库存重量', '报错信息'],
  897. filterVal: ['fname', 'stockweight', 'msg'],
  898. tableDatas: arr,
  899. sheetName: 'ExcelDatas1'
  900. }
  901. ]
  902. json2excel(ExcelDatas1, '初始化库存报错信息', true, 'xlsx')
  903. }
  904. },
  905. initialData() {
  906. console.log('点击了初始化库存保存')
  907. this.isokDisable = true
  908. setTimeout(() => {
  909. this.isokDisable = false
  910. }, 1000)
  911. var rulesStockweight = /^\d+(\.\d{1,2})?$/
  912. for (let i = 0; i < this.initial.list.length; i++) {
  913. if (!rulesStockweight.test(parseFloat(this.initial.list[i].stockweight))) {
  914. this.$message({ type: 'warning', message: '库存重量不可小于0,且保留俩位小数', duration: 2000 })
  915. return false
  916. }
  917. }
  918. this.requestParam.common = { 'returnmap': '0' }
  919. this.requestParam.data = []
  920. this.requestParam.data[0] = { 'name': 'clearFS', 'type': 'e', 'parammaps': {
  921. 'pastureid': Cookies.get('pastureid')
  922. }}
  923. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.initial.list }}
  924. this.requestParam.data[1].children = []
  925. this.requestParam.data[1].children[0] = { 'name': 'insertFeedstorage', 'type': 'e', 'parammaps': {
  926. pastureid: '@insertSpotList.pastureid',
  927. feedid: '@insertSpotList.feedid',
  928. fname: '@insertSpotList.fname',
  929. pcpde: '@insertSpotList.pcpde',
  930. stockweight: '@insertSpotList.stockweight',
  931. price: '@insertSpotList.price'
  932. }}
  933. ExecDataByConfig(this.requestParam).then(response => {
  934. if (response.msg === 'fail') {
  935. failproccess(response, this.$notify)
  936. } else {
  937. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  938. this.create.dialogFormVisible = false
  939. this.getList()
  940. }
  941. })
  942. }
  943. }
  944. }
  945. </script>
  946. <style lang="scss" scoped>
  947. .search{margin-top:10px;}
  948. .table{margin-top:10px;}
  949. </style>