7156f5dfd23bf5d9bdab51fee8d82a1a9c41758e.svn-base 37 KB

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