91de2782166f71fd73b66e5c4d5898eb9bc3bf15.svn-base 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button v-if="isRoleEdit" class="success" style="float: left;margin-right:10px;" @click="handleCreate">新增</el-button>
  5. <el-button v-if="isRoleEdit" class="danger" style="float: left;margin-right:10px;" @click="handleDelete">删除</el-button>
  6. <el-button v-if="isRoleEdit" class="warning" style="float: left;margin-right:10px;" @click="handleCopy">复制</el-button>
  7. <el-button v-if="isRoleEdit" class="import" style="float: right;" @click="handleImport">导入</el-button>
  8. <el-dropdown style="float: right;margin-right: 10px;">
  9. <el-button class="export">导出</el-button>
  10. <el-dropdown-menu slot="dropdown">
  11. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  12. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  13. </el-dropdown-menu>
  14. </el-dropdown>
  15. </div>
  16. <div class="search">
  17. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  18. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  19. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  20. <el-select v-model="table.getdataListParm.parammaps.barid" placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  21. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  22. </el-select>
  23. <el-select v-model="table.getdataListParm.parammaps.times" filterable placeholder="班次" class="filter-item" style="width: 120px;" clearable>
  24. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  25. </el-select>
  26. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  27. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  28. </div>
  29. <div class="table">
  30. <el-table
  31. :key="table.tableKey"
  32. v-loading="table.listLoading"
  33. element-loading-text="给我一点时间"
  34. :data="table.list"
  35. border
  36. fit
  37. highlight-current-row
  38. style="width: 100%;"
  39. :row-style="rowStyle"
  40. :cell-style="cellStyle"
  41. class="elTable table-fixed"
  42. @selection-change="handleSelectionChange"
  43. >
  44. <el-table-column type="selection" align="center" width="50" />
  45. <el-table-column label="序号" align="center" type="index" width="50px">
  46. <template slot-scope="scope">
  47. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="栏舍名称" min-width="150px" align="center">
  51. <template slot-scope="scope">
  52. <span>{{ scope.row.barname }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="班次" min-width="90px" align="center">
  56. <template slot-scope="scope">
  57. <span>{{ scope.row.timesstr }}</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="鲜样重量(g)" min-width="100px" align="center">
  61. <template slot-scope="scope">
  62. <span>{{ scope.row.freshweight }}</span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="烘干重量(g)" min-width="100px" align="center">
  66. <template slot-scope="scope">
  67. <span>{{ scope.row.dryweight }}</span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="理论干物质" min-width="100px" align="center">
  71. <template slot-scope="scope">
  72. <span>{{ scope.row.thoweight }}</span>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="实际干物质" min-width="100px" align="center">
  76. <template slot-scope="scope">
  77. <span>{{ scope.row.actweight }}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="操作人" min-width="90px" align="center">
  81. <template slot-scope="scope">
  82. <span>{{ scope.row.emp }}</span>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="操作日期" min-width="100px" align="center">
  86. <template slot-scope="scope">
  87. <span>{{ scope.row.operatetime }}</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  91. <template slot-scope="{row}">
  92. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  93. <el-button v-if="isRoleEdit" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  98. </div>
  99. <!-- 新增/编辑 -->
  100. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="70%">
  101. <div class="app-add">
  102. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="135px" style="width: 90%;margin:0 auto 50px">
  103. <el-row>
  104. <el-col :span="12">
  105. <el-form-item label="栏舍名称:" prop="barid">
  106. <el-select ref="barid" v-model="create.temp.barid" :disabled="create.dialogStatus=='update'" filterable placeholder="栏舍名称" class="filter-item" style="width: 100%;" @change="changeBar">
  107. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  108. </el-select>
  109. </el-form-item>
  110. </el-col>
  111. <el-col :span="12">
  112. <el-form-item label="班次:" prop="times">
  113. <el-select ref="times" v-model="create.temp.times" :disabled="create.dialogStatus=='update'" filterable placeholder="班次" class="filter-item" style="width: 100%;">
  114. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  115. </el-select>
  116. </el-form-item>
  117. </el-col>
  118. </el-row>
  119. <el-row>
  120. <el-col :span="12">
  121. <el-form-item label="鲜样重量(g):" prop="freshweight">
  122. <el-input ref="freshweight" v-model="create.temp.freshweight" class="filter-item" placeholder="最多两位小数" type="number" @blur="blurFreshweight" />
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="12">
  126. <el-form-item label="烘干重量(g):" prop="dryweight">
  127. <el-input ref="dryweight" v-model="create.temp.dryweight" class="filter-item" placeholder="最多两位小数" type="number" @blur="blurDryweight" />
  128. </el-form-item>
  129. </el-col>
  130. </el-row>
  131. <el-row>
  132. <el-col :span="12">
  133. <el-form-item label="理论干物质:" prop="thoweight">
  134. <span>{{ create.temp.thoweight }}</span>
  135. </el-form-item>
  136. </el-col>
  137. <el-col :span="12">
  138. <el-form-item label="实际干物质:" prop="actweight">
  139. <span>{{ create.temp.actweight }}</span>
  140. </el-form-item>
  141. </el-col>
  142. </el-row>
  143. <el-row>
  144. <el-col :span="12">
  145. <el-form-item label="操作人:" prop="emp">
  146. <el-select ref="emp" v-model="create.temp.emp" filterable placeholder="操作人" class="filter-item" style="width: 100%;" @blur="blurEmp">
  147. <el-option v-for="item in create.noteTakerList" :key="item.myId" :label="item.emp" :value="item.emp" />
  148. </el-select>
  149. </el-form-item>
  150. </el-col>
  151. <el-col :span="12">
  152. <el-form-item label="操作日期:" prop="operatetime">
  153. <el-date-picker v-model="create.temp.operatetime" :disabled="create.dialogStatus=='update'" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" style="width: 100%;" :clearable="false" @change="changeOperatetime" />
  154. </el-form-item>
  155. </el-col>
  156. </el-row>
  157. </el-form>
  158. <div slot="footer" class="dialog-footer">
  159. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  160. <el-button v-if="create.dialogStatus==='create'" class="success" :disabled="isokDisable" @click="createDataAgain()">确认新增</el-button>
  161. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  162. </div>
  163. </div>
  164. </el-dialog>
  165. </div>
  166. </template>
  167. <script>
  168. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  169. import Cookies from 'js-cookie'
  170. import { parseTime } from '@/utils/index.js'
  171. import Pagination from '@/components/Pagination'
  172. import { MessageBox } from 'element-ui'
  173. export default {
  174. name: 'FormulaDryMatter',
  175. components: { Pagination },
  176. data() {
  177. return {
  178. isRoleEdit: [],
  179. requestParams: [
  180. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }},
  181. { name: 'getSysoptEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid'), 'inforname': 'times' }}
  182. ],
  183. houseNameList: [], // 栏舍名称
  184. frequencyList: [], // 班次
  185. table: {
  186. getdataListParm: {
  187. name: 'getFtdryList',
  188. page: 1,
  189. offset: 1,
  190. pagecount: 10,
  191. returntype: 'Map',
  192. parammaps: {
  193. pastureid: Cookies.get('pastureid'),
  194. barid: '',
  195. times: '',
  196. startTime: '',
  197. stopTime: '',
  198. inputDatetime: ''
  199. }
  200. },
  201. tableKey: 0,
  202. list: [],
  203. total: 0,
  204. listLoading: true,
  205. temp: {}
  206. },
  207. // 新增/编辑
  208. create: {
  209. dialogFormVisible: false,
  210. dialogStatus: '',
  211. temp: { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d}'), emp: Cookies.get('employename'), barid: '', barname: '', freshweight: '', dryweight: '', thoweight: '', actweight: '', times: '' },
  212. rules: {
  213. barid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  214. times: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  215. freshweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  216. dryweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  217. },
  218. // 操作人
  219. getdataListParm: {
  220. name: 'getFtdryEmpHis',
  221. page: 1,
  222. offset: 1,
  223. pagecount: 10,
  224. returntype: 'Map',
  225. parammaps: {
  226. pastureid: Cookies.get('pastureid')
  227. }
  228. },
  229. // 理论干物质
  230. getdataListParm2: {
  231. name: 'getFtdrytweight',
  232. page: 1,
  233. offset: 1,
  234. pagecount: 10,
  235. returntype: 'Map',
  236. parammaps: {
  237. pastureid: Cookies.get('pastureid'),
  238. barid: '',
  239. date: ''
  240. }
  241. },
  242. noteTakerList: [] // 记录人
  243. },
  244. textMap: {
  245. create: '新增',
  246. update: '编辑'
  247. },
  248. requestParam: {},
  249. isokDisable: false,
  250. selectList: [],
  251. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  252. cellStyle: { padding: 0 + 'px' }
  253. }
  254. },
  255. created() {
  256. this.getList()
  257. this.getDownList()
  258. this.getButtons()
  259. },
  260. methods: {
  261. getButtons() {
  262. const Edit = 'FormulaDryMatter'
  263. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  264. this.isRoleEdit = isRoleEdit
  265. },
  266. getDownList() {
  267. GetDataByNames(this.requestParams).then(response => {
  268. this.houseNameList = response.data.getBarListEnable.list
  269. if (response.data.getSysoptEnable.list !== null) {
  270. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  271. const obj = {}
  272. obj.id = String(i)
  273. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  274. this.frequencyList.push(obj)
  275. }
  276. } else {
  277. this.frequencyList = []
  278. }
  279. })
  280. },
  281. handleBefore() {
  282. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  283. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  284. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  285. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  286. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  287. this.$forceUpdate()
  288. }
  289. },
  290. handleNext() {
  291. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  292. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  293. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  294. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  295. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  296. this.$forceUpdate()
  297. }
  298. },
  299. getList() {
  300. this.table.listLoading = true
  301. GetDataByName(this.table.getdataListParm).then(response => {
  302. console.log('table数据', response.data.list)
  303. if (response.data.list !== null) {
  304. this.table.list = response.data.list
  305. this.table.pageNum = response.data.pageNum
  306. this.table.pageSize = response.data.pageSize
  307. this.table.total = response.data.total
  308. } else {
  309. this.table.list = []
  310. }
  311. setTimeout(() => {
  312. this.table.listLoading = false
  313. }, 100)
  314. })
  315. },
  316. handleSearch() {
  317. console.log('点击了查询')
  318. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  319. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  320. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  321. } else {
  322. this.table.getdataListParm.parammaps.inputDatetime = ''
  323. this.table.getdataListParm.parammaps.startTime = ''
  324. this.table.getdataListParm.parammaps.stopTime = ''
  325. }
  326. this.table.getdataListParm.offset = 1
  327. this.getList()
  328. },
  329. handleRefresh() {
  330. console.log('点击了重置')
  331. this.table.getdataListParm.parammaps.barid = ''
  332. this.table.getdataListParm.parammaps.times = ''
  333. this.table.getdataListParm.parammaps.startTime = ''
  334. this.table.getdataListParm.parammaps.stopTime = ''
  335. this.table.getdataListParm.parammaps.inputDatetime = ''
  336. this.table.getdataListParm.offset = 1
  337. this.getList()
  338. },
  339. // 新增
  340. resetTemp() {
  341. this.create.temp = { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d}'), emp: Cookies.get('employename'), barid: '', barname: '', freshweight: '', dryweight: '', thoweight: '', actweight: '', times: '' }
  342. },
  343. blurEmp(item) {
  344. this.create.temp.emp = item.target.value
  345. },
  346. // 栏舍名称
  347. changeBar(item) {
  348. this.create.temp.barname = this.houseNameList.find(obj => obj.id === item).bname
  349. this.getThoweight()
  350. },
  351. changeOperatetime() {
  352. this.getThoweight()
  353. },
  354. // 理论干物质
  355. getThoweight() {
  356. this.create.getdataListParm2.parammaps.date = this.create.temp.operatetime
  357. this.create.getdataListParm2.parammaps.barid = this.create.temp.barid
  358. GetDataByName(this.create.getdataListParm2).then(response => {
  359. if (response.data.list !== null) {
  360. this.create.temp.thoweight = response.data.list[0].thoweight
  361. } else {
  362. this.create.temp.thoweight = 0
  363. }
  364. })
  365. },
  366. // 操作人
  367. getNoteTakerList() {
  368. GetDataByName(this.create.getdataListParm).then(response => {
  369. if (response.data.list !== null) {
  370. for (let i = 0; i < response.data.list.length; i++) {
  371. response.data.list[i].myId = i
  372. }
  373. this.create.noteTakerList = response.data.list
  374. console.log('记录人数据', response.data.list)
  375. console.log(this.create.noteTakerList)
  376. } else {
  377. this.create.noteTakerList = []
  378. }
  379. })
  380. },
  381. blurFreshweight() {
  382. if (this.create.temp.dryweight !== '' && this.create.temp.freshweight !== '') {
  383. this.create.temp.actweight = parseFloat(this.create.temp.dryweight) / parseFloat(this.create.temp.freshweight)
  384. this.create.temp.actweight = this.create.temp.actweight.toFixed(2)
  385. }
  386. },
  387. blurDryweight() {
  388. if (this.create.temp.freshweight !== '' && this.create.temp.dryweight !== '') {
  389. this.create.temp.actweight = parseFloat(this.create.temp.dryweight) / parseFloat(this.create.temp.freshweight)
  390. this.create.temp.actweight = this.create.temp.actweight.toFixed(2)
  391. }
  392. },
  393. handleCreate() {
  394. console.log('点击了新增')
  395. this.resetTemp()
  396. this.getNoteTakerList()
  397. this.create.dialogStatus = 'create'
  398. this.create.dialogFormVisible = true
  399. },
  400. createData() {
  401. console.log('点击了新增保存')
  402. this.isokDisable = true
  403. setTimeout(() => {
  404. this.isokDisable = false
  405. }, 1000)
  406. this.$refs['temp'].validate(valid => {
  407. if (valid) {
  408. this.isokDisable = true
  409. setTimeout(() => {
  410. this.isokDisable = false
  411. }, 1000)
  412. const weight = /^\d+(\.\d{1,2})?$/
  413. // 鲜样重量/烘干重量
  414. if (!weight.test(parseFloat(this.create.temp.freshweight)) || !weight.test(parseFloat(this.create.temp.dryweight))) {
  415. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  416. return false
  417. }
  418. this.requestParam.name = 'insertFtdry'
  419. this.requestParam.parammaps = this.create.temp
  420. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  421. PostDataByName(this.requestParam).then(response => {
  422. console.log('新增保存发送参数', this.requestParam)
  423. if (response.msg !== 'fail') {
  424. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  425. this.create.dialogFormVisible = false
  426. this.getList()
  427. } else {
  428. const barid = new RegExp("key 'barid'")
  429. if (barid.test(response.data)) {
  430. this.$message({ type: 'error', message: '该栏舍该班次今日配方干物质已存在,不可重复生成', duration: 2000 })
  431. } else {
  432. failproccess(response, this.$notify)
  433. }
  434. }
  435. })
  436. }
  437. })
  438. },
  439. createDataAgain() {
  440. console.log('点击了新增保存')
  441. this.isokDisable = true
  442. setTimeout(() => {
  443. this.isokDisable = false
  444. }, 1000)
  445. this.$refs['temp'].validate(valid => {
  446. if (valid) {
  447. this.isokDisable = true
  448. setTimeout(() => {
  449. this.isokDisable = false
  450. }, 1000)
  451. const weight = /^\d+(\.\d{1,2})?$/
  452. // 鲜样重量/烘干重量
  453. if (!weight.test(parseFloat(this.create.temp.freshweight)) || !weight.test(parseFloat(this.create.temp.dryweight))) {
  454. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  455. return false
  456. }
  457. this.requestParam.name = 'insertFtdry'
  458. this.requestParam.parammaps = this.create.temp
  459. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  460. PostDataByName(this.requestParam).then(response => {
  461. console.log('新增保存发送参数', this.requestParam)
  462. if (response.msg !== 'fail') {
  463. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  464. this.resetTemp()
  465. this.getList()
  466. this.getNoteTakerList()
  467. } else {
  468. const barid = new RegExp("key 'barid'")
  469. if (barid.test(response.data)) {
  470. this.$message({ type: 'error', message: '该栏舍该班次今日配方干物质已存在,不可重复生成', duration: 2000 })
  471. } else {
  472. failproccess(response, this.$notify)
  473. }
  474. }
  475. })
  476. }
  477. })
  478. },
  479. // 编辑
  480. handleUpdate(row) {
  481. console.log('点击了编辑', row)
  482. row.barid = String(row.barid)
  483. this.create.temp = Object.assign({}, row)
  484. this.create.temp.id = row.id
  485. this.getNoteTakerList()
  486. this.create.dialogStatus = 'update'
  487. this.create.dialogFormVisible = true
  488. },
  489. updateData() {
  490. this.isokDisable = true
  491. setTimeout(() => {
  492. this.isokDisable = false
  493. }, 1000)
  494. this.$refs['temp'].validate(valid => {
  495. if (valid) {
  496. this.isokDisable = true
  497. setTimeout(() => {
  498. this.isokDisable = false
  499. }, 1000)
  500. const weight = /^\d+(\.\d{1,2})?$/
  501. // 鲜样重量/烘干重量
  502. if (!weight.test(parseFloat(this.create.temp.freshweight)) || !weight.test(parseFloat(this.create.temp.dryweight))) {
  503. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  504. return false
  505. }
  506. this.requestParam.name = 'updateFtdry'
  507. this.requestParam.parammaps = this.create.temp
  508. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  509. PostDataByName(this.requestParam).then(response => {
  510. console.log('新增保存发送参数', this.requestParam)
  511. if (response.msg !== 'fail') {
  512. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  513. this.create.dialogFormVisible = false
  514. this.getList()
  515. } else {
  516. failproccess(response, this.$notify)
  517. }
  518. })
  519. }
  520. })
  521. },
  522. // 删除
  523. handleRowDelete(row) {
  524. console.log('点击了行内删除')
  525. MessageBox.confirm('是否确认删除此信息?', {
  526. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  527. }).then(() => {
  528. this.selectList = []
  529. this.requestParam.name = 'deleteFtdry'
  530. this.requestParam.parammaps = {}
  531. this.requestParam.parammaps.pastureid = row.pastureid
  532. this.requestParam.parammaps.id = row.id
  533. PostDataByName(this.requestParam).then(response => {
  534. if (response.msg === 'fail') {
  535. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  536. } else {
  537. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  538. this.getList()
  539. }
  540. })
  541. }).catch(() => {
  542. this.$message({ type: 'info', message: '已取消删除' })
  543. })
  544. },
  545. handleSelectionChange(val) {
  546. console.log('勾选数据', val)
  547. this.selectList = val
  548. },
  549. handleDelete() {
  550. console.log('点击了删除')
  551. if (this.selectList.length == 0) {
  552. this.$message({ type: 'error', message: '请选择配方干物质', duration: 2000 })
  553. } else {
  554. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  555. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  556. }).then(() => {
  557. console.log(this.selectList)
  558. this.requestParam.common = { 'returnmap': '0' }
  559. this.requestParam.data = []
  560. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  561. this.requestParam.data[0].children = []
  562. this.requestParam.data[0].children[0] = { 'name': 'deleteFtdry', 'type': 'e', 'parammaps': {
  563. id: '@insertSpotList.id',
  564. pastureid: '@insertSpotList.pastureid'
  565. }}
  566. ExecDataByConfig(this.requestParam).then(response => {
  567. console.log('删除保存发送参数', this.requestParam)
  568. if (response.msg === 'fail') {
  569. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  570. } else {
  571. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  572. this.getList()
  573. }
  574. })
  575. })
  576. }
  577. },
  578. // 复制
  579. handleCopy() {
  580. console.log('点击了复制')
  581. if (this.selectList.length == 0) {
  582. this.$message({ type: 'error', message: '请选择配方干物质', duration: 2000 })
  583. } else if (this.selectList.length == 1) {
  584. MessageBox.confirm('是否确认复制此信息?', {
  585. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  586. }).then(() => {
  587. this.requestParam.name = 'copyFtdry'
  588. this.requestParam.parammaps = {}
  589. this.requestParam.parammaps.pastureid = this.selectList[0].pastureid
  590. this.requestParam.parammaps.id = this.selectList[0].id
  591. PostDataByName(this.requestParam).then(response => {
  592. if (response.msg === 'fail') {
  593. const barid = new RegExp("key 'barid'")
  594. if (barid.test(response.data)) {
  595. this.$message({ type: 'error', message: '该栏舍该班次今日配方干物质已存在,不可重复生成', duration: 2000 })
  596. } else {
  597. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  598. }
  599. } else {
  600. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  601. this.getList()
  602. }
  603. })
  604. }).catch(() => {
  605. this.$message({ type: 'info', message: '已取消删除' })
  606. })
  607. } else {
  608. this.$message({ type: 'error', message: '请选择一条配方干物质', duration: 2000 })
  609. }
  610. },
  611. // 导出
  612. handleExport(item) {
  613. if (item == 1) {
  614. console.log('点击了导出模板')
  615. } else {
  616. console.log('点击了导出数据')
  617. }
  618. },
  619. // 导入
  620. handleImport() {
  621. console.log('点击了导入')
  622. }
  623. }
  624. }
  625. </script>
  626. <style lang="scss" scoped>
  627. .search{padding-top:10px;clear: both;}
  628. .table{margin-top:10px;}
  629. </style>