1131a6b9cc5898c215a708897a4951175d3ebfbb.svn-base 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  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="cancelClose" @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="cancelClose" @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.operateweight = (parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight))
  563. }
  564. }
  565. if (this.create.createTemp.operateweight !== '' && this.create.createTemp.pricenew !== '') {
  566. this.create.createTemp.sumprice = parseFloat(this.create.createTemp.operateweight) * parseFloat(this.create.createTemp.pricenew)
  567. this.create.createTemp.sumprice = this.create.createTemp.sumprice.toFixed(2)
  568. } else {
  569. this.create.createTemp.sumprice = ''
  570. }
  571. },
  572. // 毛重
  573. blurGrossweight() {
  574. // 毛重grossweight皮重tareweight入库重量operateweight
  575. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  576. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.operateweight)
  577. }
  578. if (this.create.createTemp.grossweight !== '' && this.create.createTemp.operateweight !== '') {
  579. if (parseFloat(this.create.createTemp.operateweight) > parseFloat(this.create.createTemp.grossweight)) {
  580. this.create.createTemp.grossweight = this.create.createTemp.operateweight
  581. this.create.createTemp.tareweight = parseFloat(this.create.createTemp.operateweight) - 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.tareweight) + 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.operateweight = (parseFloat(this.create.createTemp.grossweight) - parseFloat(this.create.createTemp.tareweight))
  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 !== '') {
  638. if (this.create.createTemp.operateweight == 0) {
  639. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  640. return false
  641. } else {
  642. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  643. this.$message({ type: 'error', message: '入库重量请输入自然数并保留两位小数', duration: 2000 })
  644. return false
  645. }
  646. }
  647. }
  648. // 单价
  649. if (this.create.createTemp.pricenew == 0) {
  650. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  651. return false
  652. } else {
  653. if (!keepTwoNum.test(parseFloat(this.create.createTemp.pricenew))) {
  654. this.$message({ type: 'error', message: '单价请输入自然数并保留两位小数', duration: 2000 })
  655. return false
  656. }
  657. }
  658. // 总价
  659. if (this.create.createTemp.pricenew !== '' && this.create.createTemp.operateweight !== '') {
  660. if (this.create.createTemp.sumprice == 0) {
  661. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  662. return false
  663. } else {
  664. if (!keepTwoNum.test(parseFloat(this.create.createTemp.sumprice))) {
  665. this.$message({ type: 'error', message: '总价请输入自然数并保留两位小数', duration: 2000 })
  666. return false
  667. }
  668. }
  669. }
  670. // 毛重
  671. if (this.create.createTemp.grossweight !== '') {
  672. if (this.create.createTemp.grossweight == 0) {
  673. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  674. return false
  675. } else {
  676. if (!keepTwoNum.test(parseFloat(this.create.createTemp.grossweight))) {
  677. this.$message({ type: 'error', message: '毛重请输入自然数并保留两位小数', duration: 2000 })
  678. return false
  679. }
  680. }
  681. }
  682. // 皮重
  683. if (this.create.createTemp.tareweight !== '') {
  684. if (this.create.createTemp.tareweight == 0) {
  685. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  686. return false
  687. } else {
  688. if (!keepTwoNum.test(parseFloat(this.create.createTemp.tareweight))) {
  689. this.$message({ type: 'error', message: '皮重请输入自然数并保留两位小数', duration: 2000 })
  690. return false
  691. }
  692. }
  693. }
  694. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  695. }).then(() => {
  696. this.isokDisable = true
  697. setTimeout(() => {
  698. this.isokDisable = false
  699. }, 1000)
  700. this.requestParam.common = { 'returnmap': '0' }
  701. this.requestParam.data = []
  702. this.requestParam.data[0] = { 'name': 'insertFeedlaid', 'type': 'e', 'parammaps': {
  703. 'pastureid': this.create.createTemp.pastureid,
  704. 'laiddate': this.create.createTemp.laiddate,
  705. 'feedid': this.create.createTemp.feedid,
  706. 'feedname': this.create.createTemp.feedname,
  707. 'providerid': this.create.createTemp.providerid,
  708. 'providername': this.create.createTemp.providername,
  709. 'contractcode': this.create.createTemp.contractcode,
  710. 'operateweight': this.create.createTemp.operateweight,
  711. 'grossweight': this.create.createTemp.grossweight,
  712. 'tareweight': this.create.createTemp.tareweight,
  713. 'sumprice': this.create.createTemp.sumprice,
  714. 'licence': this.create.createTemp.licence,
  715. 'pcpde': this.create.createTemp.pcpde,
  716. 'remark': this.create.createTemp.remark,
  717. 'createdate': this.create.createTemp.createdate,
  718. 'createemp': this.create.createTemp.createemp,
  719. 'startweight': this.create.createTemp.startweight,
  720. 'priceold': this.create.createTemp.priceold,
  721. 'pricenew': this.create.createTemp.pricenew,
  722. 'wagonnumber': this.create.createTemp.wagonnumber
  723. }}
  724. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  725. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  726. 'operateweight': this.create.createTemp.operateweight,
  727. 'pastureid': this.create.createTemp.pastureid,
  728. 'feedid': this.create.createTemp.feedid,
  729. 'fname': this.create.createTemp.fname,
  730. 'pcpde': this.create.createTemp.pcpde,
  731. 'stockweight': this.create.createTemp.startweight,
  732. 'price': this.create.createTemp.pricenew
  733. }}
  734. }
  735. console.log('点击了新增入库单保存', this.requestParam)
  736. ExecDataByConfig(this.requestParam).then(response => {
  737. if (response.msg === 'fail') {
  738. failproccess(response, this.$notify)
  739. } else {
  740. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  741. this.create.dialogFormVisible = false
  742. this.getList()
  743. }
  744. })
  745. })
  746. }
  747. })
  748. },
  749. handleUpdate(row) {
  750. console.log('点击了编辑')
  751. this.create.dialogStatus = 'update'
  752. this.create.dialogFormVisible = true
  753. row.feedid = String(row.feedid)
  754. this.create.createTemp = Object.assign({}, row)
  755. },
  756. updateData() {
  757. this.$refs['createTemp'].validate(valid => {
  758. if (valid) {
  759. if (this.create.createTemp.operateweight == '' && this.create.createTemp.grossweight == '') {
  760. this.$message({ type: 'error', message: '请输入入库重量或毛重', duration: 2000 })
  761. return false
  762. }
  763. MessageBox.confirm('是否确认保存当前内容', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  764. }).then(() => {
  765. this.isokDisable = true
  766. setTimeout(() => {
  767. this.isokDisable = false
  768. }, 1000)
  769. this.requestParam.common = { 'returnmap': '0' }
  770. this.requestParam.data = []
  771. this.requestParam.data[0] = { 'name': 'updateFeedlaid', 'type': 'e', 'parammaps': {
  772. 'pastureid': this.create.createTemp.pastureid,
  773. 'id': this.create.createTemp.id,
  774. 'laiddate': this.create.createTemp.laiddate,
  775. 'feedid': this.create.createTemp.feedid,
  776. 'feedname': this.create.createTemp.feedname,
  777. 'providerid': this.create.createTemp.providerid,
  778. 'providername': this.create.createTemp.providername,
  779. 'contractcode': this.create.createTemp.contractcode,
  780. 'operateweight': this.create.createTemp.operateweight,
  781. 'grossweight': this.create.createTemp.grossweight,
  782. 'tareweight': this.create.createTemp.tareweight,
  783. 'sumprice': this.create.createTemp.sumprice,
  784. 'licence': this.create.createTemp.licence,
  785. 'pcpde': this.create.createTemp.pcpde,
  786. 'remark': this.create.createTemp.remark,
  787. 'createdate': this.create.createTemp.createdate,
  788. 'createemp': this.create.createTemp.createemp,
  789. 'startweight': this.create.createTemp.startweight,
  790. 'priceold': this.create.createTemp.priceold,
  791. 'pricenew': this.create.createTemp.pricenew,
  792. 'wagonnumber': this.create.createTemp.wagonnumber
  793. }}
  794. if (this.create.createTemp.operateweight !== '' && parseFloat(this.create.createTemp.operateweight) > 0) {
  795. this.requestParam.data[1] = { 'name': 'insertFeedstorageLaid', 'type': 'e', 'parammaps': {
  796. 'operateweight': this.create.createTemp.operateweight,
  797. 'pastureid': this.create.createTemp.pastureid,
  798. 'feedid': this.create.createTemp.feedid,
  799. 'fname': this.create.createTemp.fname,
  800. 'pcpde': this.create.createTemp.pcpde,
  801. 'stockweight': this.create.createTemp.startweight,
  802. 'price': this.create.createTemp.pricenew
  803. }}
  804. }
  805. console.log('点击了新增入库单保存', this.requestParam)
  806. ExecDataByConfig(this.requestParam).then(response => {
  807. if (response.msg === 'fail') {
  808. failproccess(response, this.$notify)
  809. } else {
  810. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  811. this.create.dialogFormVisible = false
  812. this.getList()
  813. }
  814. })
  815. })
  816. }
  817. })
  818. },
  819. handleSee(row) {
  820. console.log('点击了查看')
  821. this.create.dialogStatus = 'see'
  822. this.create.dialogFormVisible = true
  823. this.create.createTemp = Object.assign({}, row)
  824. },
  825. handleInitial() {
  826. console.log('点击了初始化库存')
  827. this.initial.dialogStatus = 'initial'
  828. this.initial.dialogFormVisible = true
  829. this.getInitialList()
  830. },
  831. getInitialList() {
  832. this.initial.listLoading = true
  833. GetDataByName(this.initial.getdataListParm).then(response => {
  834. console.log('table数据', response.data.list)
  835. if (response.data.list !== null) {
  836. this.initial.list = response.data.list
  837. this.initial.pageNum = response.data.pageNum
  838. this.initial.pageSize = response.data.pageSize
  839. this.initial.total = response.data.total
  840. } else {
  841. this.initial.list = []
  842. }
  843. setTimeout(() => {
  844. this.initial.listLoading = false
  845. }, 100)
  846. })
  847. },
  848. handleInitialExport() {
  849. console.log('点击了初始化库存导出')
  850. const ExcelDatas = [
  851. {
  852. tHeader: ['饲料名称', '库存重量'],
  853. filterVal: ['fname', 'stockweight'],
  854. tableDatas: this.initial.list,
  855. sheetName: '初始化库存'
  856. }
  857. ]
  858. json2excel(ExcelDatas, '初始化库存', true, 'xlsx')
  859. },
  860. async handleInitialImport(eve) {
  861. const file = eve.raw
  862. if (!file) return
  863. let reader = await upload(file)
  864. const worker = xlsx.read(reader, { type: 'binary' })
  865. // 将返回的数据转换为json对象的数据
  866. reader = xlsx.utils.sheet_to_json(worker.Sheets[worker.SheetNames[0]])
  867. console.log(reader)
  868. const arr = []
  869. reader.forEach(item => {
  870. const obj = {}
  871. for (const key in this.initial.character) {
  872. if (!this.initial.character.hasOwnProperty(key)) break
  873. let v = this.initial.character[key]
  874. const text = v.text
  875. const type = v.type
  876. v = item[text] || ''
  877. type === 'string' ? (v = String(v)) : null
  878. type === 'number' ? (v = Number(v)) : null
  879. obj[key] = v
  880. }
  881. arr.push(obj)
  882. })
  883. console.log('导入处理后数据', arr)
  884. var sum = 0
  885. for (let i = 0; i < this.initial.list.length; i++) {
  886. for (let j = 0; j < arr.length; j++) {
  887. if (this.initial.list[i].fname == arr[j].fname) {
  888. this.initial.list[i].stockweight = arr[j].stockweight
  889. sum++
  890. arr.splice(j, 1)
  891. }
  892. }
  893. }
  894. console.log(arr)
  895. for (let i = 0; i < arr.length; i++) {
  896. this.$set(arr[i], 'msg', '饲料名称与系统不匹配')
  897. }
  898. console.log(sum)
  899. this.$message({ title: '成功', message: '导入成功:' + sum + '条!', type: 'success', duration: 2000 })
  900. this.$notify({ title: '失败', message: '导入失败:' + arr.length + '条!', type: 'danger', duration: 2000 })
  901. if (arr.length > 0) {
  902. const ExcelDatas1 = [
  903. {
  904. tHeader: ['饲料名称', '库存重量', '报错信息'],
  905. filterVal: ['fname', 'stockweight', 'msg'],
  906. tableDatas: arr,
  907. sheetName: 'ExcelDatas1'
  908. }
  909. ]
  910. json2excel(ExcelDatas1, '初始化库存报错信息', true, 'xlsx')
  911. }
  912. },
  913. initialData() {
  914. console.log('点击了初始化库存保存')
  915. this.isokDisable = true
  916. setTimeout(() => {
  917. this.isokDisable = false
  918. }, 1000)
  919. var rulesStockweight = /^\d+(\.\d{1,2})?$/
  920. for (let i = 0; i < this.initial.list.length; i++) {
  921. if (!rulesStockweight.test(parseFloat(this.initial.list[i].stockweight))) {
  922. this.$message({ type: 'warning', message: '库存重量不可小于0,且保留俩位小数', duration: 2000 })
  923. return false
  924. }
  925. }
  926. this.requestParam.common = { 'returnmap': '0' }
  927. this.requestParam.data = []
  928. this.requestParam.data[0] = { 'name': 'clearFS', 'type': 'e', 'parammaps': {
  929. 'pastureid': Cookies.get('pastureid')
  930. }}
  931. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.initial.list }}
  932. this.requestParam.data[1].children = []
  933. this.requestParam.data[1].children[0] = { 'name': 'insertFeedstorage', 'type': 'e', 'parammaps': {
  934. pastureid: '@insertSpotList.pastureid',
  935. feedid: '@insertSpotList.feedid',
  936. fname: '@insertSpotList.fname',
  937. pcpde: '@insertSpotList.pcpde',
  938. stockweight: '@insertSpotList.stockweight',
  939. price: '@insertSpotList.price'
  940. }}
  941. ExecDataByConfig(this.requestParam).then(response => {
  942. if (response.msg === 'fail') {
  943. failproccess(response, this.$notify)
  944. } else {
  945. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  946. this.create.dialogFormVisible = false
  947. this.getList()
  948. }
  949. })
  950. }
  951. }
  952. }
  953. </script>
  954. <style lang="scss" scoped>
  955. .search{margin-top:10px;}
  956. .table{margin-top:10px;}
  957. </style>