9fb2c7e9ddb23c97e3a763eb517f78b4cd4fd960.svn-base 19 KB

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