0f396a095c134a94bcbcbc02c274c4382f1e8db2.svn-base 27 KB

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