9a8137ce0b1422dd3e3c3ed6af7dac5f346b71b9.svn-base 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button class="success" @click="handleCreate">新增</el-button>
  5. <el-button class="import" style="float: right;" @click="handleImport">导入</el-button>
  6. <el-dropdown style="float: right;margin-right: 10px;">
  7. <el-button class="export">导出</el-button>
  8. <el-dropdown-menu slot="dropdown">
  9. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  10. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  11. </el-dropdown-menu>
  12. </el-dropdown>
  13. </div>
  14. <div class="search">
  15. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  16. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  17. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  18. <el-select v-model="table.getdataListParm.parammaps.usetype" placeholder="操作类型" class="filter-item" style="width: 120px;" clearable>
  19. <el-option v-for="item in operationTypeList" :key="item.id" :label="item.label" :value="item.value" />
  20. </el-select>
  21. <el-autocomplete v-model="table.getdataListParm.parammaps.feedname" value-key="feedname" class="inline-input filter-item" :fetch-suggestions="tableFeedNameSearch" placeholder="饲料名称" style="width:250px" @select="handleSelectTableFeedName">
  22. <template slot-scope="{ item }">
  23. <span>{{ item.feedname }}</span>
  24. </template>
  25. </el-autocomplete>
  26. <el-select v-model="table.getdataListParm.parammaps.cowclassid" filterable placeholder="请选择牲畜类别" class="filter-item" style="width: 150px;" clearable>
  27. <el-option v-for="item in livestockList" :key="item.id" :label="item.mixname" :value="item.id" />
  28. </el-select>
  29. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  30. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  31. </div>
  32. <div class="table">
  33. <el-table
  34. :key="table.tableKey"
  35. v-loading="table.listLoading"
  36. element-loading-text="给我一点时间"
  37. :data="table.list"
  38. border
  39. fit
  40. highlight-current-row
  41. style="width: 100%;"
  42. :row-style="rowStyle"
  43. :cell-style="cellStyle"
  44. class="elTable table-fixed"
  45. >
  46. <el-table-column label="序号" align="center" type="index" width="50px">
  47. <template slot-scope="scope">
  48. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="出库日期" min-width="130px" align="center">
  52. <template slot-scope="scope">
  53. <span>{{ scope.row.usedate }}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="牲畜类别" min-width="130px" align="center">
  57. <template slot-scope="scope">
  58. <span>{{ scope.row.cowclass }}</span>
  59. </template>
  60. </el-table-column>
  61. <el-table-column label="饲料名称" min-width="110px" align="center">
  62. <template slot-scope="scope">
  63. <span>{{ scope.row.feedname }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="操作重量(kg)" min-width="110px" align="center">
  67. <template slot-scope="scope">
  68. <span>{{ scope.row.operateweight }}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="操作类型" min-width="110px" align="center">
  72. <template slot-scope="scope">
  73. <span>{{ scope.row.usetype }}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="备注" min-width="110px" align="center">
  77. <template slot-scope="scope">
  78. <span>{{ scope.row.remark }}</span>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="操作人" min-width="110px" align="center">
  82. <template slot-scope="scope">
  83. <span>{{ scope.row.createemp }}</span>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
  87. <template slot-scope="{row}">
  88. <el-button class="miniPrimary" @click="handleSee(row)">查看</el-button>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  93. </div>
  94. <!-- 新增/编辑 -->
  95. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="80%">
  96. <div class="app-add">
  97. <el-form ref="createTemp" :rules="create.rules" :model="create.createTemp" label-position="right" label-width="150px" style="width: 90%;height:300px;margin:0 auto 50px">
  98. <el-row>
  99. <el-col :span="12">
  100. <el-form-item label="操作类型:" prop="usetype">
  101. <el-select v-model="create.createTemp.usetype" placeholder="操作类型" class="filter-item" style="width: 100%;" :disabled="create.dialogStatus==='see'" @change="changeUsetype">
  102. <el-option v-for="item in operationTypeList" :key="item.id" :label="item.label" :value="item.value" />
  103. </el-select>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="12">
  107. <el-form-item label="出库日期:" prop="usedate">
  108. <el-date-picker v-model="create.createTemp.usedate" class="filter-item" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 100%;" type="datetime" placeholder="出库日期" :disabled="create.dialogStatus==='see'" />
  109. </el-form-item>
  110. </el-col>
  111. </el-row>
  112. <el-row>
  113. <el-col :span="12">
  114. <el-form-item label="饲料名称:" prop="feedname">
  115. <el-autocomplete v-model="create.createTemp.feedname" :disabled="create.dialogStatus==='see'" value-key="feedname" class="inline-input" :fetch-suggestions="feedNameSearch" placeholder="请选择饲料名称" style="width:100%" @select="handleSelectFeedName" @blur="blurFeedName">
  116. <template slot-scope="{ item }">
  117. <span>{{ item.feedname }}</span>
  118. </template>
  119. </el-autocomplete>
  120. </el-form-item>
  121. </el-form-item>
  122. </el-col>
  123. <el-col :span="12">
  124. <el-form-item label="牲畜类别:" prop="cowclassid">
  125. <el-select v-model="create.createTemp.cowclassid" filterable placeholder="请选择牲畜类别" class="filter-item" style="width: 100%;" :disabled="create.dialogStatus==='see' || create.createTemp.usetype=='损耗'" @change="changeLivestock">
  126. <el-option v-for="item in livestockList" :key="item.id" :label="item.mixname" :value="item.id" />
  127. </el-select>
  128. </el-form-item>
  129. </el-col>
  130. </el-row>
  131. <el-row>
  132. <el-col :span="12">
  133. <el-form-item label="库存重量(kg):" prop="repertoryweight">
  134. <el-input ref="repertoryweight" v-model="create.createTemp.repertoryweight" class="filter-item" placeholder="最多两位小数" type="text" disabled />
  135. </el-form-item>
  136. </el-col>
  137. <el-col :span="12">
  138. <el-form-item label="操作重量(kg):" prop="operateweight">
  139. <el-input ref="operateweight" v-model="create.createTemp.operateweight" class="filter-item" placeholder="最多两位小数" type="text" :disabled="create.dialogStatus==='see'" />
  140. </el-form-item>
  141. </el-col>
  142. </el-row>
  143. <el-row>
  144. <el-col :span="12">
  145. <el-form-item label="备注:" prop="remark">
  146. <el-input ref="remark" v-model="create.createTemp.remark" class="filter-item" placeholder="1-255字符" type="text" :disabled="create.dialogStatus==='see'" />
  147. </el-form-item>
  148. </el-col>
  149. </el-row>
  150. </el-form>
  151. <div slot="footer" class="dialog-footer">
  152. <el-button class="cancel" @click="create.dialogFormVisible = false; ">关闭</el-button>
  153. <el-button v-if="create.dialogStatus==='create'" class="success" :disabled="isokDisable" @click="createData()">确认</el-button>
  154. </div>
  155. </div>
  156. </el-dialog>
  157. </div>
  158. </template>
  159. <script>
  160. import { GetDataByName, GetDataByNames, checkButtons, ExecDataByConfig, failproccess } from '@/api/common'
  161. import Pagination from '@/components/Pagination'
  162. import Cookies from 'js-cookie'
  163. import { parseTime } from '@/utils/index.js'
  164. export default {
  165. name: 'LaborConsumption',
  166. components: { Pagination },
  167. data() {
  168. return {
  169. isRoleEdit: [],
  170. requestParams: [
  171. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['人工用量操作类型'] },
  172. { name: 'getCowclassListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }}
  173. ],
  174. operationTypeList: [], // 操作类型
  175. feedNameList: [], // 饲料名称
  176. livestockList: [], // 牲畜类别
  177. table: {
  178. getdataListParm: {
  179. name: 'getFeeduseList',
  180. page: 1,
  181. offset: 1,
  182. pagecount: 10,
  183. returntype: 'Map',
  184. parammaps: {
  185. inputDatetime: '',
  186. pastureid: Cookies.get('pastureid'),
  187. startTime: '',
  188. stopTime: '',
  189. usetype: '',
  190. feedid: '',
  191. cowclassid: ''
  192. }
  193. },
  194. tableKey: 0,
  195. list: [],
  196. total: 0,
  197. listLoading: true
  198. },
  199. create: {
  200. dialogFormVisible: false,
  201. dialogStatus: '',
  202. createTemp: {
  203. pastureid: Cookies.get('pastureid'), usedate: parseTime(new Date(), '{y}-{m}-{d}'), feedid: '', feedname: '', cowclassid: '', cowclass: '', usetype: '', operateweight: '', repertoryweight: '', createemp: '', remark: '', price: ''
  204. },
  205. getfeedNameParm: {
  206. name: 'getFeedstorageuse',
  207. offset: 0,
  208. pagecount: '',
  209. parammaps: { pastureid: Cookies.get('pastureid') }
  210. },
  211. rules: {
  212. usetype: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  213. usedate: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  214. feedname: [{ type: 'string', required: true, message: '必填', trigger: 'change' }],
  215. operateweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  216. }
  217. },
  218. textMap: {
  219. create: '新增',
  220. see: '查看'
  221. },
  222. requestParam: {},
  223. isokDisable: false,
  224. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  225. cellStyle: { padding: 0 + 'px' }
  226. }
  227. },
  228. created() {
  229. this.getList()
  230. this.getDownList()
  231. this.getButtons()
  232. },
  233. methods: {
  234. getButtons() {
  235. const Edit = 'SystemConsumption'
  236. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  237. this.isRoleEdit = isRoleEdit
  238. },
  239. getDownList() {
  240. GetDataByNames(this.requestParams).then(response => {
  241. this.operationTypeList = response.data.getDictByName.list
  242. this.livestockList = response.data.getCowclassListEnable.list
  243. })
  244. },
  245. handleBefore() {
  246. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  247. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  248. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  249. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  250. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  251. this.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  252. this.table.getdataListParm.parammaps.stopTime = parseTime(stop, '{y}-{m}-{d}')
  253. this.$forceUpdate()
  254. }
  255. },
  256. handleNext() {
  257. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  258. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  259. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  260. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  261. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  262. this.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  263. this.table.getdataListParm.parammaps.stopTime = parseTime(stop, '{y}-{m}-{d}')
  264. this.$forceUpdate()
  265. }
  266. },
  267. getList() {
  268. this.table.listLoading = true
  269. GetDataByName(this.table.getdataListParm).then(response => {
  270. console.log('table数据', response.data.list)
  271. if (response.data.list !== null) {
  272. this.table.list = response.data.list
  273. this.table.pageNum = response.data.pageNum
  274. this.table.pageSize = response.data.pageSize
  275. this.table.total = response.data.total
  276. } else {
  277. this.table.list = []
  278. }
  279. setTimeout(() => {
  280. this.table.listLoading = false
  281. }, 100)
  282. })
  283. },
  284. handleSearch() {
  285. console.log('点击了查询')
  286. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  287. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  288. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  289. } else {
  290. this.table.getdataListParm.parammaps.inputDatetime = ''
  291. this.table.getdataListParm.parammaps.startTime = ''
  292. this.table.getdataListParm.parammaps.stopTime = ''
  293. }
  294. this.table.getdataListParm.offset = 1
  295. this.getList()
  296. },
  297. handleRefresh() {
  298. console.log('点击了重置')
  299. this.table.getdataListParm.parammaps.inputDatetime = ''
  300. this.table.getdataListParm.parammaps.startTime = ''
  301. this.table.getdataListParm.parammaps.stopTime = ''
  302. this.table.getdataListParm.parammaps.feedid = ''
  303. this.table.getdataListParm.parammaps.cowclassid = ''
  304. this.table.getdataListParm.parammaps.ischarge = ''
  305. this.table.getdataListParm.parammaps.usetype = ''
  306. this.table.getdataListParm.parammaps.feedname = ''
  307. this.table.getdataListParm.parammaps.cowclassid = ''
  308. },
  309. resetCreateTemp() {
  310. this.create.createTemp = {
  311. pastureid: Cookies.get('pastureid'), usedate: parseTime(new Date(), '{y}-{m}-{d}'), feedid: '', feedname: '', cowclassid: '', cowclass: '', usetype: '', operateweight: '', repertoryweight: '', createemp: Cookies.get('employename'), remark: '', price: ''
  312. }
  313. },
  314. // 操作类型
  315. changeUsetype(item) {
  316. console.log(item)
  317. if (item == '损耗') {
  318. console.log(item)
  319. this.create.createTemp.cowclassid = ''
  320. this.create.createTemp.cowclass = ''
  321. }
  322. },
  323. tableFeedNameSearch(queryString, cb) {
  324. this.create.getfeedNameParm.parammaps['feedname'] = queryString
  325. GetDataByName(this.create.getfeedNameParm).then(response => {
  326. console.log('模糊查询搜索data', response.data.list)
  327. if (response.data.list == null) {
  328. cb([])
  329. } else {
  330. cb(response.data.list)
  331. }
  332. })
  333. },
  334. handleSelectTableFeedName(item) {
  335. this.table.getdataListParm.parammaps.feedid = item.feedid
  336. },
  337. // 饲料名称
  338. feedNameSearch(queryString, cb) {
  339. this.create.getfeedNameParm.parammaps['feedname'] = queryString
  340. GetDataByName(this.create.getfeedNameParm).then(response => {
  341. console.log('模糊查询搜索data', response.data.list)
  342. if (response.data.list == null) {
  343. cb([])
  344. } else {
  345. cb(response.data.list)
  346. }
  347. })
  348. },
  349. handleSelectFeedName(item) {
  350. console.log(item)
  351. this.create.createTemp.feedname = item.feedname
  352. this.create.createTemp.feedid = item.feedid
  353. this.create.createTemp.price = item.price
  354. this.create.createTemp.pcpde = item.pcpde
  355. this.create.createTemp.repertoryweight = item.stockweight
  356. },
  357. blurFeedName() {
  358. this.create.createTemp.feedname = ''
  359. this.create.createTemp.feedid = ''
  360. this.create.createTemp.price = ''
  361. this.create.createTemp.pcpde = ''
  362. this.create.createTemp.repertoryweight = ''
  363. },
  364. // 牲畜类别
  365. changeLivestock(item) {
  366. this.create.createTemp.cowclass = this.livestockList.find(obj => obj.id == item).classname
  367. },
  368. handleCreate() {
  369. console.log('点击了新增')
  370. this.resetCreateTemp()
  371. this.create.dialogStatus = 'create'
  372. this.create.dialogFormVisible = true
  373. },
  374. createData() {
  375. console.log('点击了新增保存')
  376. this.$refs['createTemp'].validate(valid => {
  377. if (valid) {
  378. this.isokDisable = true
  379. setTimeout(() => {
  380. this.isokDisable = false
  381. }, 1000)
  382. if (this.create.createTemp.usetype == '人工用料') {
  383. if (this.create.createTemp.cowclassid == '') {
  384. this.$message({ type: 'error', message: '请选择牲畜类别', duration: 2000 })
  385. return false
  386. }
  387. }
  388. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  389. // 操作重量
  390. if (this.create.createTemp.operateweight == 0) {
  391. this.$message({ type: 'error', message: '操作重量请输入自然数并保留两位小数', duration: 2000 })
  392. return false
  393. } else {
  394. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  395. this.$message({ type: 'error', message: '操作重量请输入自然数并保留两位小数', duration: 2000 })
  396. return false
  397. }
  398. }
  399. this.requestParam.common = { 'returnmap': '0' }
  400. this.requestParam.data = []
  401. this.requestParam.data[0] = { 'name': 'insertFeeduse', 'type': 'e', 'parammaps': {
  402. 'pastureid': this.create.createTemp.pastureid,
  403. 'usedate': this.create.createTemp.usedate,
  404. 'feedid': this.create.createTemp.feedid,
  405. 'feedname': this.create.createTemp.feedname,
  406. 'cowclassid': this.create.createTemp.cowclassid,
  407. 'cowclass': this.create.createTemp.cowclass,
  408. 'usetype': this.create.createTemp.usetype,
  409. 'operateweight': this.create.createTemp.operateweight,
  410. 'repertoryweight': this.create.createTemp.repertoryweight,
  411. 'createemp': this.create.createTemp.createemp,
  412. 'remark': this.create.createTemp.remark,
  413. 'price': this.create.createTemp.price
  414. }}
  415. this.requestParam.data[1] = { 'name': 'insertFeedstorageUse', 'type': 'e', 'parammaps': {
  416. 'pastureid': this.create.createTemp.pastureid,
  417. 'feedid': this.create.createTemp.feedid,
  418. 'operateweight': this.create.createTemp.operateweight,
  419. 'fname': this.create.createTemp.feedname,
  420. 'pcpde': this.create.createTemp.pcpde,
  421. 'price': this.create.createTemp.price
  422. }}
  423. ExecDataByConfig(this.requestParam).then(response => {
  424. if (response.msg === 'fail') {
  425. failproccess(response, this.$notify)
  426. } else {
  427. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  428. this.create.dialogFormVisible = false
  429. this.getList()
  430. }
  431. })
  432. }
  433. })
  434. },
  435. handleSee(row) {
  436. console.log('点击了查看')
  437. this.create.dialogStatus = 'see'
  438. this.create.dialogFormVisible = true
  439. this.create.createTemp = Object.assign({}, row)
  440. },
  441. handleRowDelete(row) {
  442. console.log('点击了行内删除')
  443. },
  444. // 导出
  445. handleExport(item) {
  446. if (item == 1) {
  447. console.log('点击了导出模板')
  448. } else {
  449. console.log('点击了导出数据')
  450. }
  451. },
  452. // 导入
  453. handleImport() {
  454. console.log('点击了导入')
  455. }
  456. }
  457. }
  458. </script>
  459. <style lang="scss" scoped>
  460. .search{margin-top:10px;}
  461. .table{margin-top:10px;}
  462. </style>
  463. <style lang="scss">
  464. .typeSelect span .el-popover__reference .el-input--suffix {
  465. .el-input__inner{
  466. height:40px !important;
  467. }
  468. }
  469. </style>