539378c5ba0352bce73fa79a6abd8d26a5e1f7df.svn-base 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  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-upload v-if="isRoleEdit" style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  8. <el-button class="import" style="float: right;">导入</el-button>
  9. </el-upload>
  10. <el-dropdown style="float: right;margin-right: 10px;">
  11. <el-button class="export">导出</el-button>
  12. <el-dropdown-menu slot="dropdown">
  13. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  14. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  15. </el-dropdown-menu>
  16. </el-dropdown>
  17. </div>
  18. <div class="search">
  19. <el-date-picker v-model="table.getdataListParm.parammaps.inputDatetime" class="inputDatetime filter-item" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 250px;" />
  20. <el-button class="el-icon-arrow-left elIconArrowLeft" @click="handleBefore" />
  21. <el-button class="el-icon-arrow-right elIconArrowRight" @click="handleNext" />
  22. <el-select v-model="table.getdataListParm.parammaps.barid" placeholder="栏舍名称" class="filter-item" style="width: 120px;" clearable>
  23. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  24. </el-select>
  25. <el-select v-model="table.getdataListParm.parammaps.times" filterable placeholder="班次" class="filter-item" style="width: 120px;" clearable>
  26. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  27. </el-select>
  28. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  29. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  30. </div>
  31. <div class="table">
  32. <el-table
  33. :key="table.tableKey"
  34. v-loading="table.listLoading"
  35. element-loading-text="给我一点时间"
  36. :data="table.list"
  37. border
  38. fit
  39. highlight-current-row
  40. style="width: 100%;"
  41. :row-style="rowStyle"
  42. :cell-style="cellStyle"
  43. class="elTable table-fixed"
  44. @selection-change="handleSelectionChange"
  45. >
  46. <el-table-column type="selection" align="center" width="50" />
  47. <el-table-column label="序号" align="center" type="index" width="50px">
  48. <template slot-scope="scope">
  49. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="栏舍名称" min-width="150px" align="center">
  53. <template slot-scope="scope">
  54. <span>{{ scope.row.barname }}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="班次" min-width="90px" align="center">
  58. <template slot-scope="scope">
  59. <span>{{ scope.row.times }}</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="第一层" align="center">
  63. <el-table-column prop="onerate" label="比例(%)" min-width="90px" align="center" />
  64. <el-table-column prop="oneweight" label="重量(g)" min-width="90px" align="center" />
  65. </el-table-column>
  66. <el-table-column label="第二层" align="center">
  67. <el-table-column prop="tworate" label="比例(%)" min-width="90px" align="center" />
  68. <el-table-column prop="twoweight" label="重量(g)" min-width="90px" align="center" />
  69. </el-table-column>
  70. <el-table-column label="第三层" align="center">
  71. <el-table-column prop="threerate" label="比例(%)" min-width="90px" align="center" />
  72. <el-table-column prop="threeweight" label="重量(g)" min-width="90px" align="center" />
  73. </el-table-column>
  74. <el-table-column label="第四层" align="center">
  75. <el-table-column prop="fourrate" label="比例(%)" min-width="90px" align="center" />
  76. <el-table-column prop="fourweight" label="重量(g)" min-width="90px" align="center" />
  77. </el-table-column>
  78. <el-table-column label="备注" min-width="90px" align="center">
  79. <template slot-scope="scope">
  80. <span>{{ scope.row.remark }}</span>
  81. </template>
  82. </el-table-column>
  83. <el-table-column label="操作人" min-width="90px" align="center">
  84. <template slot-scope="scope">
  85. <span>{{ scope.row.emp }}</span>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="操作日期" min-width="90px" align="center">
  89. <template slot-scope="scope">
  90. <span>{{ scope.row.operatetime }}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  94. <template slot-scope="{row}">
  95. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  96. <el-button v-if="isRoleEdit" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  101. </div>
  102. <!-- 新增/编辑 -->
  103. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  104. <div class="app-add">
  105. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="150px" style="width: 100%;margin:0 auto 50px">
  106. <el-row>
  107. <el-col :span="24">
  108. <h3 style="width: 150px;text-align: right;">栏舍信息</h3>
  109. </el-col>
  110. </el-row>
  111. <el-row>
  112. <el-col v-if="create.dialogStatus=='create'" :span="6">
  113. <el-form-item label="栏舍名称:" prop="barid">
  114. <el-select ref="barid" v-model="create.temp.barid" filterable placeholder="栏舍名称" class="filter-item" style="width: 100%;" @change="changeBar">
  115. <el-option v-for="item in houseNameList" :key="item.id" :label="item.bname" :value="item.id" />
  116. </el-select>
  117. </el-form-item>
  118. </el-col>
  119. <el-col v-else :span="6">
  120. <el-form-item label="栏舍名称:" prop="barname">
  121. <el-input ref="barname" v-model="create.temp.barname" disabled class="filter-item" placeholder="barname" />
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="6">
  125. <el-form-item label="班次:" prop="times">
  126. <el-select ref="times" v-model="create.temp.times" :disabled="create.dialogStatus=='update'" filterable placeholder="班次" class="filter-item" style="width: 100%;">
  127. <el-option v-for="item in frequencyList" :key="item.id" :label="item.name" :value="item.id" />
  128. </el-select>
  129. </el-form-item>
  130. </el-col>
  131. </el-row>
  132. <el-row>
  133. <el-col :span="24">
  134. <h3 style="width: 150px;text-align: right;">重量比例</h3>
  135. </el-col>
  136. </el-row>
  137. <el-row>
  138. <el-col :span="6">
  139. <el-form-item label="第一层重量(g):" prop="oneweight">
  140. <el-input ref="oneweight" v-model="create.temp.oneweight" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" style="width: 100%;" @blur="blurWeight" />
  141. </el-form-item>
  142. </el-col>
  143. <el-col :span="6">
  144. <el-form-item label="第二层重量(g):" prop="twoweight">
  145. <el-input ref="twoweight" v-model="create.temp.twoweight" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" style="width: 100%;" @blur="blurWeight" />
  146. </el-form-item>
  147. </el-col>
  148. <el-col :span="6">
  149. <el-form-item label="第三层重量(g):" prop="threeweight">
  150. <el-input ref="threeweight" v-model="create.temp.threeweight" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" style="width: 100%;" @blur="blurWeight" />
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="6">
  154. <el-form-item label="第四层重量(g):" prop="fourweight">
  155. <el-input ref="fourweight" v-model="create.temp.fourweight" class="filter-item" placeholder="最多两位小数" type="number" step="0.01" style="width: 100%;" @blur="blurWeight" />
  156. </el-form-item>
  157. </el-col>
  158. </el-row>
  159. <el-row>
  160. <el-col :span="6">
  161. <el-form-item label="第一层比例 (%):">
  162. <span>{{ create.temp.onerate }}</span>
  163. <span>{{ create.temp.onerange }}</span>
  164. </el-form-item>
  165. </el-col>
  166. <el-col :span="6">
  167. <el-form-item label="第二层比例 (%):">
  168. <span>{{ create.temp.tworate }}</span>
  169. <span>{{ create.temp.tworange }}</span>
  170. </el-form-item>
  171. </el-col>
  172. <el-col :span="6">
  173. <el-form-item label="第三层比例 (%):">
  174. <span>{{ create.temp.threerate }}</span>
  175. <span>{{ create.temp.threerange }}</span>
  176. </el-form-item>
  177. </el-col>
  178. <el-col :span="6">
  179. <el-form-item label="第四层比例 (%):">
  180. <span>{{ create.temp.fourrate }}</span>
  181. <span>{{ create.temp.fourrange }}</span>
  182. </el-form-item>
  183. </el-col>
  184. </el-row>
  185. <el-row>
  186. <el-col :span="24">
  187. <h3 style="width: 150px;text-align: right;">操作详情</h3>
  188. </el-col>
  189. </el-row>
  190. <el-row>
  191. <el-col :span="6">
  192. <el-form-item label="操作人:" prop="emp">
  193. <el-select ref="emp" v-model="create.temp.emp" filterable placeholder="操作人" class="filter-item" style="width: 100%;" @blur="blurEmp">
  194. <el-option v-for="item in create.noteTakerList" :key="item.myId" :label="item.emp" :value="item.emp" />
  195. </el-select>
  196. </el-form-item>
  197. </el-col>
  198. <el-col :span="6">
  199. <el-form-item label="操作日期:" prop="operatetime">
  200. <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" />
  201. </el-form-item>
  202. </el-col>
  203. <el-col :span="12">
  204. <el-form-item label="备注:" prop="remark">
  205. <el-input ref="remark" v-model="create.temp.remark" class="filter-item" placeholder="1-255字符" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width: 100%;" />
  206. </el-form-item>
  207. </el-col>
  208. </el-row>
  209. </el-form>
  210. <div slot="footer" class="dialog-footer">
  211. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  212. <el-button v-if="create.dialogStatus==='create'" class="success" :disabled="isokDisable" @click="createDataAgain()">确认新增</el-button>
  213. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="success" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  214. </div>
  215. </div>
  216. </el-dialog>
  217. </div>
  218. </template>
  219. <script>
  220. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  221. import Cookies from 'js-cookie'
  222. import { parseTime, json2excel } from '@/utils/index.js'
  223. import Pagination from '@/components/Pagination'
  224. import { MessageBox } from 'element-ui'
  225. import { getToken } from '@/utils/auth'
  226. export default {
  227. name: 'PennsylvaniaSieve',
  228. components: { Pagination },
  229. data() {
  230. return {
  231. isRoleEdit: [],
  232. requestParams: [
  233. { name: 'getBarListEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid') }},
  234. { name: 'getSysoptEnable', offset: 0, pagecount: 0, parammaps: { 'pastureid': Cookies.get('pastureid'), 'inforname': 'times' }}
  235. ],
  236. houseNameList: [], // 栏舍名称
  237. frequencyList: [], // 班次
  238. table: {
  239. getdataListParm: {
  240. name: 'getPennsieveList',
  241. page: 1,
  242. offset: 1,
  243. pagecount: 10,
  244. returntype: 'Map',
  245. parammaps: {
  246. pastureid: Cookies.get('pastureid'),
  247. barid: '',
  248. times: '',
  249. startTime: '',
  250. stopTime: '',
  251. inputDatetime: ''
  252. }
  253. },
  254. tableKey: 0,
  255. list: [],
  256. total: 0,
  257. listLoading: true,
  258. temp: {}
  259. },
  260. // 新增/编辑
  261. create: {
  262. dialogFormVisible: false,
  263. dialogStatus: '',
  264. temp: { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d}'), emp: Cookies.get('employename'), barid: '', barname: '', times: '', oneweight: '', twoweight: '', threeweight: '', fourweight: '', onerate: '', tworate: '', threerate: '', fourrate: '', tworange: '', threerange: '', fourrange: '', remark: '', ccid: '', ccname: '' },
  265. rules: {
  266. barid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  267. times: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  268. oneweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  269. twoweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  270. threeweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  271. fourweight: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  272. },
  273. // 操作人
  274. getdataListParm: {
  275. name: 'getPennsieveEmpHis',
  276. page: 1,
  277. offset: 1,
  278. pagecount: 10,
  279. returntype: 'Map',
  280. parammaps: {
  281. pastureid: Cookies.get('pastureid')
  282. }
  283. },
  284. // 宾州筛范围
  285. getdataListParm2: {
  286. name: 'getPennsieveRange',
  287. page: 1,
  288. offset: 1,
  289. pagecount: 1,
  290. returntype: 'Map',
  291. parammaps: {
  292. pastureid: Cookies.get('pastureid'),
  293. barid: '',
  294. date: ''
  295. }
  296. },
  297. noteTakerList: [] // 记录人
  298. },
  299. textMap: {
  300. create: '新增',
  301. update: '编辑'
  302. },
  303. requestParam: {},
  304. download: {
  305. getdataListParm: {
  306. name: 'getPennsieveList',
  307. page: 1,
  308. offset: 1,
  309. pagecount: 0,
  310. returntype: 'Map',
  311. parammaps: {
  312. pastureid: Cookies.get('pastureid'),
  313. barid: '',
  314. times: '',
  315. startTime: '',
  316. stopTime: '',
  317. inputDatetime: ''
  318. }
  319. },
  320. list: []
  321. },
  322. isokDisable: false,
  323. selectList: [],
  324. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  325. cellStyle: { padding: 0 + 'px' }
  326. }
  327. },
  328. computed: {
  329. // 设置请求头
  330. headers() {
  331. return {
  332. token: getToken()
  333. }
  334. },
  335. uploadData() {
  336. return {
  337. name: '颛孙洋洋-宾州筛',
  338. importParams: '栏舍名称,班次,第一层重量(g),第二层重量(g),第三层重量(g),第四层重量(g),备注,操作人,操作日期',
  339. sheetname: 'SheetJS'
  340. }
  341. },
  342. // 设置上传地址
  343. uploadExcelUrl() {
  344. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  345. }
  346. },
  347. created() {
  348. this.getList()
  349. this.getDownList()
  350. this.getButtons()
  351. },
  352. methods: {
  353. getButtons() {
  354. const Edit = 'PennsylvaniaSieve'
  355. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  356. this.isRoleEdit = isRoleEdit
  357. },
  358. getDownList() {
  359. GetDataByNames(this.requestParams).then(response => {
  360. this.houseNameList = response.data.getBarListEnable.list
  361. if (response.data.getSysoptEnable.list !== null) {
  362. for (let i = 1; i <= response.data.getSysoptEnable.list[0].inforvalue; i++) {
  363. const obj = {}
  364. obj.id = String(i)
  365. if (i == 1) { obj.name = '第一班' } else if (i == 2) { obj.name = '第二班' } else if (i == 3) { obj.name = '第三班' } else if (i == 4) { obj.name = '第四班' }
  366. this.frequencyList.push(obj)
  367. }
  368. } else {
  369. this.frequencyList = []
  370. }
  371. })
  372. },
  373. handleBefore() {
  374. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  375. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() - 1))
  376. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() - 1))
  377. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  378. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  379. this.$forceUpdate()
  380. }
  381. },
  382. handleNext() {
  383. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  384. var start = new Date(this.table.getdataListParm.parammaps.inputDatetime[0].setDate(this.table.getdataListParm.parammaps.inputDatetime[0].getDate() + 1))
  385. var stop = new Date(this.table.getdataListParm.parammaps.inputDatetime[1].setDate(this.table.getdataListParm.parammaps.inputDatetime[1].getDate() + 1))
  386. this.table.getdataListParm.parammaps.inputDatetime.length = 0
  387. this.table.getdataListParm.parammaps.inputDatetime.push(start, stop)
  388. this.$forceUpdate()
  389. }
  390. },
  391. getList() {
  392. this.table.listLoading = true
  393. GetDataByName(this.table.getdataListParm).then(response => {
  394. console.log('table数据', response.data.list)
  395. if (response.data.list !== null) {
  396. this.table.list = response.data.list
  397. this.table.pageNum = response.data.pageNum
  398. this.table.pageSize = response.data.pageSize
  399. this.table.total = response.data.total
  400. } else {
  401. this.table.list = []
  402. }
  403. setTimeout(() => {
  404. this.table.listLoading = false
  405. }, 100)
  406. })
  407. },
  408. handleSearch() {
  409. console.log('点击了查询')
  410. if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
  411. this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  412. this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  413. } else {
  414. this.table.getdataListParm.parammaps.inputDatetime = ''
  415. this.table.getdataListParm.parammaps.startTime = ''
  416. this.table.getdataListParm.parammaps.stopTime = ''
  417. }
  418. this.table.getdataListParm.offset = 1
  419. this.getList()
  420. },
  421. handleRefresh() {
  422. console.log('点击了重置')
  423. this.table.getdataListParm.parammaps.barid = ''
  424. this.table.getdataListParm.parammaps.times = ''
  425. this.table.getdataListParm.parammaps.startTime = ''
  426. this.table.getdataListParm.parammaps.stopTime = ''
  427. this.table.getdataListParm.parammaps.inputDatetime = ''
  428. this.table.getdataListParm.offset = 1
  429. this.getList()
  430. },
  431. // 新增
  432. resetTemp() {
  433. this.create.temp = { pastureid: Cookies.get('pastureid'), operatetime: parseTime(new Date(), '{y}-{m}-{d}'), emp: Cookies.get('employename'), barid: '', barname: '', times: '', oneweight: '', twoweight: '', threeweight: '', fourweight: '', onerate: '', tworate: '', threerate: '', fourrate: '', tworange: '', threerange: '', fourrange: '', remark: '', ccid: '', ccname: '' }
  434. },
  435. blurEmp(item) {
  436. this.create.temp.emp = item.target.value
  437. },
  438. // 栏舍名称
  439. changeBar(item) {
  440. this.create.temp.barname = this.houseNameList.find(obj => obj.id === item).bname
  441. this.getRange()
  442. },
  443. changeOperatetime() {
  444. this.getRange()
  445. },
  446. // 宾州筛范围
  447. getRange() {
  448. this.create.getdataListParm2.parammaps.date = this.create.temp.operatetime
  449. this.create.getdataListParm2.parammaps.barid = this.create.temp.barid
  450. GetDataByName(this.create.getdataListParm2).then(response => {
  451. if (response.data.list !== null) {
  452. this.create.temp.onerange = response.data.list[0].oneRange
  453. this.create.temp.tworange = response.data.list[0].twoRange
  454. this.create.temp.threerange = response.data.list[0].threeRange
  455. this.create.temp.fourrange = response.data.list[0].fourRange
  456. this.create.temp.ccid = response.data.list[0].ccid
  457. this.create.temp.ccname = response.data.list[0].ccname
  458. } else {
  459. this.create.temp.onerange = ''
  460. this.create.temp.tworange = ''
  461. this.create.temp.threerange = ''
  462. this.create.temp.fourrange = ''
  463. this.create.temp.ccid = ''
  464. this.create.temp.ccname = ''
  465. }
  466. })
  467. },
  468. // 操作人
  469. getNoteTakerList() {
  470. GetDataByName(this.create.getdataListParm).then(response => {
  471. if (response.data.list !== null) {
  472. for (let i = 0; i < response.data.list.length; i++) {
  473. response.data.list[i].myId = i
  474. }
  475. this.create.noteTakerList = response.data.list
  476. console.log('记录人数据', response.data.list)
  477. console.log(this.create.noteTakerList)
  478. } else {
  479. this.create.noteTakerList = []
  480. }
  481. })
  482. },
  483. blurWeight() {
  484. if (this.create.temp.oneweight && this.create.temp.twoweight && this.create.temp.threeweight && this.create.temp.fourweight) {
  485. const weightSum = parseFloat(this.create.temp.oneweight) + parseFloat(this.create.temp.twoweight) + parseFloat(this.create.temp.threeweight) + parseFloat(this.create.temp.fourweight)
  486. this.create.temp.onerate = (parseFloat(this.create.temp.oneweight) / weightSum * 100).toFixed(2)
  487. this.create.temp.tworate = (parseFloat(this.create.temp.twoweight) / weightSum * 100).toFixed(2)
  488. this.create.temp.threerate = (parseFloat(this.create.temp.threeweight) / weightSum * 100).toFixed(2)
  489. this.create.temp.fourrate = (100 - this.create.temp.onerate - this.create.temp.tworate - this.create.temp.threerate).toFixed(2)
  490. this.create.temp.onerate = String(this.create.temp.onerate)
  491. this.create.temp.tworate = String(this.create.temp.tworate)
  492. this.create.temp.threerate = String(this.create.temp.threerate)
  493. this.create.temp.fourrate = String(this.create.temp.fourrate)
  494. }
  495. },
  496. handleCreate() {
  497. console.log('点击了新增')
  498. this.resetTemp()
  499. this.getNoteTakerList()
  500. this.create.dialogStatus = 'create'
  501. this.create.dialogFormVisible = true
  502. },
  503. createData() {
  504. console.log('点击了新增保存')
  505. this.isokDisable = true
  506. setTimeout(() => {
  507. this.isokDisable = false
  508. }, 1000)
  509. this.$refs['temp'].validate(valid => {
  510. if (valid) {
  511. this.isokDisable = true
  512. setTimeout(() => {
  513. this.isokDisable = false
  514. }, 1000)
  515. const weight = /^\d+(\.\d{1,2})?$/
  516. // 第一层重量
  517. if (!weight.test(parseFloat(this.create.temp.oneweight)) || !weight.test(parseFloat(this.create.temp.twoweight)) || !weight.test(parseFloat(this.create.temp.threeweight)) || !weight.test(parseFloat(this.create.temp.fourweight))) {
  518. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  519. return false
  520. }
  521. this.requestParam.name = 'insertPennsieve'
  522. this.requestParam.parammaps = this.create.temp
  523. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  524. PostDataByName(this.requestParam).then(response => {
  525. console.log('新增保存发送参数', this.requestParam)
  526. if (response.msg !== 'fail') {
  527. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  528. this.create.dialogFormVisible = false
  529. this.getList()
  530. } else {
  531. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  532. }
  533. })
  534. }
  535. })
  536. },
  537. createDataAgain() {
  538. console.log('点击了新增保存')
  539. this.isokDisable = true
  540. setTimeout(() => {
  541. this.isokDisable = false
  542. }, 1000)
  543. this.$refs['temp'].validate(valid => {
  544. if (valid) {
  545. this.isokDisable = true
  546. setTimeout(() => {
  547. this.isokDisable = false
  548. }, 1000)
  549. const weight = /^\d+(\.\d{1,2})?$/
  550. // 第一层重量
  551. if (!weight.test(parseFloat(this.create.temp.oneweight)) || !weight.test(parseFloat(this.create.temp.twoweight)) || !weight.test(parseFloat(this.create.temp.threeweight)) || !weight.test(parseFloat(this.create.temp.fourweight))) {
  552. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  553. return false
  554. }
  555. this.requestParam.name = 'insertPennsieve'
  556. this.requestParam.parammaps = this.create.temp
  557. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  558. PostDataByName(this.requestParam).then(response => {
  559. console.log('新增保存发送参数', this.requestParam)
  560. if (response.msg !== 'fail') {
  561. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  562. this.resetTemp()
  563. this.getList()
  564. this.getNoteTakerList()
  565. } else {
  566. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  567. }
  568. })
  569. }
  570. })
  571. },
  572. // 编辑
  573. handleUpdate(row) {
  574. console.log('点击了编辑', row)
  575. row.barid = String(row.barid)
  576. this.create.temp = Object.assign({}, row)
  577. this.create.temp.id = row.id
  578. this.getNoteTakerList()
  579. this.create.dialogStatus = 'update'
  580. this.create.dialogFormVisible = true
  581. },
  582. updateData() {
  583. this.isokDisable = true
  584. setTimeout(() => {
  585. this.isokDisable = false
  586. }, 1000)
  587. this.$refs['temp'].validate(valid => {
  588. if (valid) {
  589. this.isokDisable = true
  590. setTimeout(() => {
  591. this.isokDisable = false
  592. }, 1000)
  593. const weight = /^\d+(\.\d{1,2})?$/
  594. // 第一层重量
  595. if (!weight.test(parseFloat(this.create.temp.oneweight)) || !weight.test(parseFloat(this.create.temp.twoweight)) || !weight.test(parseFloat(this.create.temp.threeweight)) || !weight.test(parseFloat(this.create.temp.fourweight))) {
  596. this.$message({ type: 'error', message: '重量不可小于0,最多保留俩位小数', duration: 2000 })
  597. return false
  598. }
  599. this.requestParam.name = 'updatePennsieve'
  600. this.requestParam.parammaps = this.create.temp
  601. if (this.create.temp.emp == '') { this.create.temp.emp = Cookies.get('employename') }
  602. PostDataByName(this.requestParam).then(response => {
  603. console.log('新增保存发送参数', this.requestParam)
  604. if (response.msg !== 'fail') {
  605. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  606. this.create.dialogFormVisible = false
  607. this.getList()
  608. } else {
  609. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  610. }
  611. })
  612. }
  613. })
  614. },
  615. // 删除
  616. handleRowDelete(row) {
  617. console.log('点击了行内删除')
  618. MessageBox.confirm('是否确认删除此信息?', {
  619. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  620. }).then(() => {
  621. this.selectList = []
  622. this.requestParam.name = 'deletePennsieve'
  623. this.requestParam.parammaps = {}
  624. this.requestParam.parammaps.pastureid = row.pastureid
  625. this.requestParam.parammaps.id = row.id
  626. PostDataByName(this.requestParam).then(response => {
  627. if (response.msg === 'fail') {
  628. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  629. } else {
  630. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  631. this.getList()
  632. }
  633. })
  634. }).catch(() => {
  635. this.$message({ type: 'info', message: '已取消删除' })
  636. })
  637. },
  638. handleSelectionChange(val) {
  639. console.log('勾选数据', val)
  640. this.selectList = val
  641. },
  642. handleDelete() {
  643. console.log('点击了删除')
  644. if (this.selectList.length == 0) {
  645. this.$message({ type: 'error', message: '请选择宾州筛', duration: 2000 })
  646. } else {
  647. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  648. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  649. }).then(() => {
  650. console.log(this.selectList)
  651. this.requestParam.common = { 'returnmap': '0' }
  652. this.requestParam.data = []
  653. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  654. this.requestParam.data[0].children = []
  655. this.requestParam.data[0].children[0] = { 'name': 'deletePennsieve', 'type': 'e', 'parammaps': {
  656. id: '@insertSpotList.id',
  657. pastureid: '@insertSpotList.pastureid'
  658. }}
  659. ExecDataByConfig(this.requestParam).then(response => {
  660. console.log('删除保存发送参数', this.requestParam)
  661. if (response.msg === 'fail') {
  662. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  663. } else {
  664. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  665. this.getList()
  666. }
  667. })
  668. })
  669. }
  670. },
  671. // 复制
  672. handleCopy() {
  673. console.log('点击了复制')
  674. if (this.selectList.length == 0) {
  675. this.$message({ type: 'error', message: '请选择宾州筛', duration: 2000 })
  676. } else if (this.selectList.length == 1) {
  677. MessageBox.confirm('是否确认复制此信息?', {
  678. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  679. }).then(() => {
  680. this.requestParam.name = 'copyPennsieve'
  681. this.requestParam.parammaps = {}
  682. this.requestParam.parammaps.pastureid = this.selectList[0].pastureid
  683. this.requestParam.parammaps.id = this.selectList[0].id
  684. PostDataByName(this.requestParam).then(response => {
  685. if (response.msg === 'fail') {
  686. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  687. } else {
  688. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  689. this.getList()
  690. }
  691. })
  692. }).catch(() => {
  693. this.$message({ type: 'info', message: '已取消删除' })
  694. })
  695. } else {
  696. this.$message({ type: 'error', message: '请选择一条宾州筛', duration: 2000 })
  697. }
  698. },
  699. // 导出
  700. handleExport(item) {
  701. if (item == 1) {
  702. console.log('点击了导出模板')
  703. } else {
  704. console.log('点击了导出数据')
  705. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  706. if (this.download.getdataListParm.parammaps.inputDatetime !== '' && this.download.getdataListParm.parammaps.inputDatetime !== null) {
  707. this.download.getdataListParm.parammaps.startTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  708. this.download.getdataListParm.parammaps.stopTime = parseTime(this.download.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  709. } else {
  710. this.download.getdataListParm.parammaps.inputDatetime = ''
  711. this.download.getdataListParm.parammaps.startTime = ''
  712. this.download.getdataListParm.parammaps.stopTime = ''
  713. }
  714. GetDataByName(this.download.getdataListParm).then(response => {
  715. if (response.data.list !== null) {
  716. this.download.list = response.data.list
  717. } else {
  718. this.download.list = []
  719. }
  720. var excelDatas = [
  721. {
  722. tHeader: ['栏舍名称', '班次', '第一层比例(%)', '第一层重量(g)', '第二层比例(%)', '第二层重量(g)', '第三层比例(%)', '第三层重量(g)', '第四层比例(%)', '第四层重量(g)', '备注', '操作人', '操作日期'],
  723. filterVal: ['barname', 'times', 'onerate', 'oneweight', 'tworate', 'twoweight', 'threerate', 'threeweight', 'fourrate', 'fourweight', 'remark', 'emp', 'operatetime'],
  724. tableDatas: this.download.list,
  725. sheetName: 'Sheet1'
  726. }
  727. ]
  728. json2excel(excelDatas, '宾州筛', true, 'xlsx')
  729. })
  730. }
  731. },
  732. beforeImport(file) {
  733. const isLt2M = file.size / 1024 / 1024 < 2
  734. if (!isLt2M) {
  735. this.$message.error('上传文件大小不能超过 2MB!')
  736. }
  737. return isLt2M
  738. },
  739. handleImportSuccess(res, file) {
  740. this.getList()
  741. if (res.msg === 'ok') {
  742. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  743. if (res.data.err_count > 0) {
  744. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  745. import('@/vendor/Export2Excel').then(excel => {
  746. const list1 = res.data.result
  747. const tHeader = [
  748. '栏舍名称', '班次', '第一层重量(g)', '第二层重量(g)', '第三层重量(g)', '第四层重量(g)', '备注', '操作人', '操作日期', '错误信息'
  749. ]
  750. const filterVal = [
  751. '栏舍名称', '班次', '第一层重量(g)', '第二层重量(g)', '第三层重量(g)', '第四层重量(g)', '备注', '操作人', '操作日期', 'error_msg'
  752. ]
  753. const data1 = this.formatJson(filterVal, list1)
  754. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '宾州筛导入报错信息', autoWidth: true, bookType: 'xlsx' })
  755. })
  756. }
  757. } else {
  758. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  759. }
  760. },
  761. formatJson(filterVal, jsonData) {
  762. return jsonData.map(v =>
  763. filterVal.map(j => {
  764. if (j === 'timestamp') {
  765. return parseTime(v[j])
  766. } else {
  767. return v[j]
  768. }
  769. })
  770. )
  771. }
  772. }
  773. }
  774. </script>
  775. <style lang="scss" scoped>
  776. .search{padding-top:10px;clear: both;}
  777. .table{margin-top:10px;}
  778. </style>