36b394af4e6e4ef990ba53e3a597ff66ca72efad.svn-base 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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" :picker-options="create.pickerOptions1" :clearable="false" 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="cancelClose" @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. pickerOptions1: {
  201. disabledDate(time) {
  202. return time.getTime() > Date.now()// 当天之前的时间可选
  203. }
  204. },
  205. dialogFormVisible: false,
  206. dialogStatus: '',
  207. createTemp: {
  208. pastureid: Cookies.get('pastureid'), usedate: parseTime(new Date(), '{y}-{m}-{d}'), feedid: '', feedname: '', cowclassid: '', cowclass: '', usetype: '', operateweight: '', repertoryweight: '', createemp: '', remark: '', price: ''
  209. },
  210. getfeedNameParm: {
  211. name: 'getFeedstorageuse',
  212. offset: 0,
  213. pagecount: '',
  214. parammaps: { pastureid: Cookies.get('pastureid') }
  215. },
  216. rules: {
  217. usetype: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  218. usedate: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  219. feedname: [{ type: 'string', required: true, message: '必填', trigger: 'change' }],
  220. operateweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  221. }
  222. },
  223. textMap: {
  224. create: '新增',
  225. see: '查看'
  226. },
  227. requestParam: {},
  228. isokDisable: false,
  229. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  230. cellStyle: { padding: 0 + 'px' }
  231. }
  232. },
  233. created() {
  234. this.getList()
  235. this.getDownList()
  236. this.getButtons()
  237. },
  238. methods: {
  239. getButtons() {
  240. const Edit = 'SystemConsumption'
  241. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  242. this.isRoleEdit = isRoleEdit
  243. },
  244. getDownList() {
  245. GetDataByNames(this.requestParams).then(response => {
  246. this.operationTypeList = response.data.getDictByName.list
  247. this.livestockList = response.data.getCowclassListEnable.list
  248. })
  249. },
  250. handleBefore() {
  251. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  252. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  253. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  254. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  255. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  256. this.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  257. this.table.getdataListParm.parammaps.stopTime = parseTime(stop, '{y}-{m}-{d}')
  258. this.$forceUpdate()
  259. }
  260. },
  261. handleNext() {
  262. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  263. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  264. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  265. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  266. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  267. this.table.getdataListParm.parammaps.startTime = parseTime(start, '{y}-{m}-{d}')
  268. this.table.getdataListParm.parammaps.stopTime = parseTime(stop, '{y}-{m}-{d}')
  269. this.$forceUpdate()
  270. }
  271. },
  272. getList() {
  273. this.table.listLoading = true
  274. GetDataByName(this.table.getdataListParm).then(response => {
  275. console.log('table数据', response.data.list)
  276. if (response.data.list !== null) {
  277. this.table.list = response.data.list
  278. this.table.pageNum = response.data.pageNum
  279. this.table.pageSize = response.data.pageSize
  280. this.table.total = response.data.total
  281. } else {
  282. this.table.list = []
  283. }
  284. setTimeout(() => {
  285. this.table.listLoading = false
  286. }, 100)
  287. })
  288. },
  289. handleSearch() {
  290. console.log('点击了查询')
  291. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  292. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  293. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  294. } else {
  295. this.table.getdataListParm.parammaps.inputDatetime = ''
  296. this.table.getdataListParm.parammaps.startTime = ''
  297. this.table.getdataListParm.parammaps.stopTime = ''
  298. }
  299. this.table.getdataListParm.offset = 1
  300. this.getList()
  301. },
  302. handleRefresh() {
  303. console.log('点击了重置')
  304. this.table.getdataListParm.parammaps.inputDatetime = ''
  305. this.table.getdataListParm.parammaps.startTime = ''
  306. this.table.getdataListParm.parammaps.stopTime = ''
  307. this.table.getdataListParm.parammaps.feedid = ''
  308. this.table.getdataListParm.parammaps.cowclassid = ''
  309. this.table.getdataListParm.parammaps.ischarge = ''
  310. this.table.getdataListParm.parammaps.usetype = ''
  311. this.table.getdataListParm.parammaps.feedname = ''
  312. this.table.getdataListParm.parammaps.cowclassid = ''
  313. },
  314. resetCreateTemp() {
  315. this.create.createTemp = {
  316. pastureid: Cookies.get('pastureid'), usedate: parseTime(new Date(), '{y}-{m}-{d}'), feedid: '', feedname: '', cowclassid: '', cowclass: '', usetype: '', operateweight: '', repertoryweight: '', createemp: Cookies.get('employename'), remark: '', price: ''
  317. }
  318. },
  319. // 操作类型
  320. changeUsetype(item) {
  321. console.log(item)
  322. if (item == '损耗') {
  323. console.log(item)
  324. this.create.createTemp.cowclassid = ''
  325. this.create.createTemp.cowclass = ''
  326. }
  327. },
  328. tableFeedNameSearch(queryString, cb) {
  329. this.create.getfeedNameParm.parammaps['feedname'] = queryString
  330. GetDataByName(this.create.getfeedNameParm).then(response => {
  331. console.log('模糊查询搜索data', response.data.list)
  332. if (response.data.list == null) {
  333. cb([])
  334. } else {
  335. cb(response.data.list)
  336. }
  337. })
  338. },
  339. handleSelectTableFeedName(item) {
  340. this.table.getdataListParm.parammaps.feedid = item.feedid
  341. },
  342. // 饲料名称
  343. feedNameSearch(queryString, cb) {
  344. this.create.getfeedNameParm.parammaps['feedname'] = queryString
  345. GetDataByName(this.create.getfeedNameParm).then(response => {
  346. console.log('模糊查询搜索data', response.data.list)
  347. if (response.data.list == null) {
  348. cb([])
  349. } else {
  350. cb(response.data.list)
  351. }
  352. })
  353. },
  354. handleSelectFeedName(item) {
  355. console.log(item)
  356. this.create.createTemp.feedname = item.feedname
  357. this.create.createTemp.feedid = item.feedid
  358. this.create.createTemp.price = item.price
  359. this.create.createTemp.pcpde = item.pcpde
  360. this.create.createTemp.repertoryweight = item.stockweight
  361. },
  362. blurFeedName() {
  363. this.create.createTemp.feedname = ''
  364. this.create.createTemp.feedid = ''
  365. this.create.createTemp.price = ''
  366. this.create.createTemp.pcpde = ''
  367. this.create.createTemp.repertoryweight = ''
  368. },
  369. // 牲畜类别
  370. changeLivestock(item) {
  371. this.create.createTemp.cowclass = this.livestockList.find(obj => obj.id == item).classname
  372. },
  373. handleCreate() {
  374. console.log('点击了新增')
  375. this.resetCreateTemp()
  376. this.create.dialogStatus = 'create'
  377. this.create.dialogFormVisible = true
  378. this.$nextTick(() => {
  379. this.$refs.createTemp.resetFields()
  380. })
  381. },
  382. createData() {
  383. console.log('点击了新增保存')
  384. this.$refs['createTemp'].validate(valid => {
  385. if (valid) {
  386. this.isokDisable = true
  387. setTimeout(() => {
  388. this.isokDisable = false
  389. }, 1000)
  390. if (this.create.createTemp.usetype == '人工用料') {
  391. if (this.create.createTemp.cowclassid == '') {
  392. this.$message({ type: 'error', message: '请选择牲畜类别', duration: 2000 })
  393. return false
  394. }
  395. }
  396. const keepTwoNum = /^\d+(\.\d{1,2})?$/
  397. // 操作重量
  398. if (this.create.createTemp.operateweight == 0) {
  399. this.$message({ type: 'error', message: '操作重量请输入自然数并保留两位小数', duration: 2000 })
  400. return false
  401. } else {
  402. if (!keepTwoNum.test(parseFloat(this.create.createTemp.operateweight))) {
  403. this.$message({ type: 'error', message: '操作重量请输入自然数并保留两位小数', duration: 2000 })
  404. return false
  405. }
  406. }
  407. this.requestParam.common = { 'returnmap': '0' }
  408. this.requestParam.data = []
  409. this.requestParam.data[0] = { 'name': 'insertFeeduse', 'type': 'e', 'parammaps': {
  410. 'pastureid': this.create.createTemp.pastureid,
  411. 'usedate': this.create.createTemp.usedate,
  412. 'feedid': this.create.createTemp.feedid,
  413. 'feedname': this.create.createTemp.feedname,
  414. 'cowclassid': this.create.createTemp.cowclassid,
  415. 'cowclass': this.create.createTemp.cowclass,
  416. 'usetype': this.create.createTemp.usetype,
  417. 'operateweight': this.create.createTemp.operateweight,
  418. 'repertoryweight': this.create.createTemp.repertoryweight,
  419. 'createemp': this.create.createTemp.createemp,
  420. 'remark': this.create.createTemp.remark,
  421. 'price': this.create.createTemp.price
  422. }}
  423. this.requestParam.data[1] = { 'name': 'insertFeedstorageUse', 'type': 'e', 'parammaps': {
  424. 'pastureid': this.create.createTemp.pastureid,
  425. 'feedid': this.create.createTemp.feedid,
  426. 'operateweight': this.create.createTemp.operateweight,
  427. 'fname': this.create.createTemp.feedname,
  428. 'pcpde': this.create.createTemp.pcpde,
  429. 'price': this.create.createTemp.price
  430. }}
  431. ExecDataByConfig(this.requestParam).then(response => {
  432. if (response.msg === 'fail') {
  433. failproccess(response, this.$notify)
  434. } else {
  435. this.$notify({ title: '', message: '成功', type: 'success', duration: 2000 })
  436. this.create.dialogFormVisible = false
  437. this.getList()
  438. }
  439. })
  440. }
  441. })
  442. },
  443. handleSee(row) {
  444. console.log('点击了查看')
  445. this.create.dialogStatus = 'see'
  446. this.create.dialogFormVisible = true
  447. this.create.createTemp = Object.assign({}, row)
  448. this.$nextTick(() => {
  449. this.$refs.createTemp.resetFields()
  450. })
  451. },
  452. handleRowDelete(row) {
  453. console.log('点击了行内删除')
  454. },
  455. // 导出
  456. handleExport(item) {
  457. if (item == 1) {
  458. console.log('点击了导出模板')
  459. } else {
  460. console.log('点击了导出数据')
  461. }
  462. },
  463. // 导入
  464. handleImport() {
  465. console.log('点击了导入')
  466. }
  467. }
  468. }
  469. </script>
  470. <style lang="scss" scoped>
  471. .search{margin-top:10px;}
  472. .table{margin-top:10px;}
  473. </style>
  474. <style lang="scss">
  475. .typeSelect span .el-popover__reference .el-input--suffix {
  476. .el-input__inner{
  477. height:40px !important;
  478. }
  479. }
  480. </style>