3a032ba173bcf754a650e6915f890016aebb0368.svn-base 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeName" @tab-click="handleTabClick">
  4. <el-tab-pane label="体况、粪便评分标准" name="first">
  5. <div class="operation">
  6. <!-- <el-button v-if="isRoleEdit" class="import" style="float: right;" @click="handleImport">导入</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-button class="export" style="float: right;margin-right: 10px;" @click="handleExport">导出</el-button>
  11. </div>
  12. <div class="table1">
  13. <el-table
  14. :key="table1.tableKey"
  15. v-loading="table1.listLoading"
  16. element-loading-text="给我一点时间"
  17. :data="table1.list"
  18. border
  19. fit
  20. highlight-current-row
  21. style="width: 100%;"
  22. :row-style="rowStyle"
  23. :cell-style="cellStyle"
  24. class="elTable table-fixed"
  25. >
  26. <el-table-column label="序号" align="center" type="index" width="50px" />
  27. <el-table-column label="配方名称" min-width="130px" align="center">
  28. <template slot-scope="scope">
  29. <span>{{ scope.row.ftname }}</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="体况评分标准" align="center" min-width="300px">
  33. <el-table-column label="体况评分标准(分)" min-width="80px" align="center">
  34. <template slot-scope="scope">
  35. <span>{{ scope.row.bodystandard }}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="数据来源" min-width="80px" align="center">
  39. <template slot-scope="scope">
  40. <span>{{ scope.row.bodysource }}</span>
  41. </template>
  42. </el-table-column>
  43. </el-table-column>
  44. <el-table-column label="粪便评分标准" align="center" min-width="300px">
  45. <el-table-column label="粪便评分标准(分)" min-width="80px" align="center">
  46. <template slot-scope="scope">
  47. <span>{{ scope.row.dungstandard }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="数据来源" min-width="80px" align="center">
  51. <template slot-scope="scope">
  52. <span>{{ scope.row.dungsource }}</span>
  53. </template>
  54. </el-table-column>
  55. </el-table-column>
  56. <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
  57. <template slot-scope="{row}">
  58. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. </div>
  63. </el-tab-pane>
  64. <el-tab-pane label="宾州筛、粪便筛标准范围" name="second">
  65. <div class="operation">
  66. <!-- <el-button v-if="isRoleEdit" class="import" style="float: right;" @click="handleImport">导入</el-button> -->
  67. <el-upload v-if="isRoleEdit" style="float: right;" :headers="headers2" :data="uploadData2" :action="uploadExcelUrl2" :show-file-list="false" :before-upload="beforeImport2" :on-success="handleImportSuccess2">
  68. <el-button class="import" style="float: right;">导入</el-button>
  69. </el-upload>
  70. <el-button class="export" style="float: right;margin-right: 10px;" @click="handleExport">导出</el-button>
  71. </div>
  72. <div class="table2">
  73. <el-table
  74. :key="table2.tableKey"
  75. v-loading="table2.listLoading"
  76. element-loading-text="给我一点时间"
  77. :data="table2.list"
  78. border
  79. fit
  80. highlight-current-row
  81. style="width: 100%;"
  82. :row-style="rowStyle"
  83. :cell-style="cellStyle"
  84. class="elTable table-fixed"
  85. >
  86. <el-table-column label="序号" align="center" type="index" width="50px" />
  87. <el-table-column label="牲畜类别" align="center" min-width="200px">
  88. <el-table-column label="牲畜父类" min-width="80px" align="center">
  89. <template slot-scope="scope">
  90. <span>{{ scope.row.parentname }}</span>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="牲畜子类" min-width="80px" align="center">
  94. <template slot-scope="scope">
  95. <span>{{ scope.row.cowname }}</span>
  96. </template>
  97. </el-table-column>
  98. </el-table-column>
  99. <el-table-column label="宾州筛" align="center" min-width="200px">
  100. <el-table-column label="宾州筛一层(%)" min-width="80px" align="center">
  101. <template slot-scope="scope">
  102. <span>{{ scope.row.bzonemin }} - {{ scope.row.bzonemax }}</span>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="宾州筛二层(%)" min-width="80px" align="center">
  106. <template slot-scope="scope">
  107. <span>{{ scope.row.bztwomin }} - {{ scope.row.bztwomax }}</span>
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="宾州筛三层(%)" min-width="80px" align="center">
  111. <template slot-scope="scope">
  112. <span>{{ scope.row.bzthreemin }} - {{ scope.row.bzthreemax }}</span>
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="宾州筛四层(%)" min-width="80px" align="center">
  116. <template slot-scope="scope">
  117. <span>{{ scope.row.bzfourmin }} - {{ scope.row.bzfourmax }}</span>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="数据来源" min-width="80px" align="center">
  121. <template slot-scope="scope">
  122. <span>{{ scope.row.bzsource }}</span>
  123. </template>
  124. </el-table-column>
  125. </el-table-column>
  126. <el-table-column label="粪便筛" align="center" min-width="300px">
  127. <el-table-column label="粪便筛一层(%)" min-width="80px" align="center">
  128. <template slot-scope="scope">
  129. <span>{{ scope.row.fbonemin }} - {{ scope.row.fbonemax }}</span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="粪便筛二层(%)" min-width="80px" align="center">
  133. <template slot-scope="scope">
  134. <span>{{ scope.row.fbtwomin }} - {{ scope.row.fbtwomax }}</span>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="粪便筛三层(%)" min-width="80px" align="center">
  138. <template slot-scope="scope">
  139. <span>{{ scope.row.fbthreemin }} - {{ scope.row.fbthreemax }}</span>
  140. </template>
  141. </el-table-column>
  142. <el-table-column label="数据来源" min-width="80px" align="center">
  143. <template slot-scope="scope">
  144. <span>{{ scope.row.fbsource }}</span>
  145. </template>
  146. </el-table-column>
  147. </el-table-column>
  148. <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width" fixed="right">
  149. <template slot-scope="{row}">
  150. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  151. </template>
  152. </el-table-column>
  153. </el-table>
  154. </div>
  155. </el-tab-pane>
  156. </el-tabs>
  157. <!-- 体况、粪便评分标准 -->
  158. <el-dialog :title="textMap[table1.dialogStatus]" :visible.sync="table1.dialogFormVisible" :close-on-click-modal="false" width="80%">
  159. <div class="app-add">
  160. <el-form ref="temp" :rules="table1.rules" :model="table1.temp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto 50px">
  161. <el-row>
  162. <el-col :span="12">
  163. <h3 style="width: 160px;float: left;">配方</h3>
  164. </el-col>
  165. </el-row>
  166. <el-row>
  167. <el-col :span="12">
  168. <el-form-item label="配方名称:" prop="ftname">
  169. <span>{{ table1.temp.ftname }}</span>
  170. </el-form-item>
  171. </el-col>
  172. </el-row>
  173. <el-row>
  174. <el-col :span="12">
  175. <h3 style="width: 160px;float: left;">体况评分标准</h3>
  176. </el-col>
  177. </el-row>
  178. <el-row>
  179. <el-col :span="12">
  180. <el-form-item label="体况评分标准(分):" prop="bodystandard">
  181. <el-select v-model="table1.temp.bodystandard" filterable placeholder="评分标准" class="filter-item" style="width: 100%;">
  182. <el-option v-for="item in physicalList" :key="item.value" :label="item.label" :value="item.label" />
  183. </el-select>
  184. </el-form-item>
  185. </el-col>
  186. <el-col :span="12">
  187. <el-form-item label="数据来源:" prop="bodysource">
  188. <el-input v-model="table1.temp.bodysource" type="textarea" placeholder="1-255字符":autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
  189. </el-form-item>
  190. </el-col>
  191. </el-row>
  192. <el-row>
  193. <el-col :span="12">
  194. <h3 style="width: 160px;float: left;">粪便评分标准</h3>
  195. </el-col>
  196. </el-row>
  197. <el-row>
  198. <el-col :span="12">
  199. <el-form-item label="粪便评分标准(分):" prop="dungstandard">
  200. <el-select v-model="table1.temp.dungstandard" filterable placeholder="粪便评分标准" class="filter-item" style="width: 100%;">
  201. <el-option v-for="item in faecesList" :key="item.value" :label="item.label" :value="item.value" />
  202. </el-select>
  203. </el-form-item>
  204. </el-col>
  205. <el-col :span="12">
  206. <el-form-item label="数据来源:" prop="dungsource">
  207. <el-input v-model="table1.temp.dungsource" type="textarea" placeholder="1-255字符" :autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
  208. </el-form-item>
  209. </el-col>
  210. </el-row>
  211. </el-form>
  212. <div slot="footer" class="dialog-footer">
  213. <el-button class="cancelClose" @click="table1.dialogFormVisible = false;getList() ">关闭</el-button>
  214. <el-button class="success" :disabled="isokDisable" @click="updateData()">确认</el-button>
  215. </div>
  216. </div>
  217. </el-dialog>
  218. <!-- 宾州筛、粪便筛标准范围 -->
  219. <el-dialog :title="textMap[table2.dialogStatus]" :visible.sync="table2.dialogFormVisible" :close-on-click-modal="false" width="80%">
  220. <div class="app-add">
  221. <el-form ref="temp" :rules="table2.rules" :model="table2.temp" label-position="right" label-width="160px" style="width: 90%;margin:0 auto 50px">
  222. <el-row>
  223. <el-col :span="10">
  224. <h3 style="width: 160px;float: left;">牲畜类别</h3>
  225. </el-col>
  226. </el-row>
  227. <el-row>
  228. <el-col :span="10">
  229. <el-form-item label="牲畜父类:" prop="parentname">
  230. <span>{{ table2.temp.parentname }}</span>
  231. </el-form-item>
  232. </el-col>
  233. <el-col :span="10">
  234. <el-form-item label="牲畜子类:" prop="cowname">
  235. <span>{{ table2.temp.cowname }}</span>
  236. </el-form-item>
  237. </el-col>
  238. </el-row>
  239. <el-row>
  240. <el-col :span="10">
  241. <h3 style="width: 160px;float: left;">宾州筛</h3>
  242. </el-col>
  243. </el-row>
  244. <el-row>
  245. <el-col :span="10">
  246. <el-form-item label="宾州筛第一层(%):">
  247. <el-input-number v-model="table2.temp.bzonemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  248. <span style="width: 1%;">-</span>
  249. <el-input-number v-model="table2.temp.bzonemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  250. </el-form-item>
  251. </el-col>
  252. <el-col :span="10">
  253. <el-form-item label="宾州筛第二层(%):">
  254. <el-input-number v-model="table2.temp.bztwomin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  255. <span style="width: 1%;">-</span>
  256. <el-input-number v-model="table2.temp.bztwomax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  257. </el-form-item>
  258. </el-col>
  259. </el-row>
  260. <el-row>
  261. <el-col :span="10">
  262. <el-form-item label="宾州筛第三层(%):">
  263. <el-input-number v-model="table2.temp.bzthreemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  264. <span style="width: 1%;">-</span>
  265. <el-input-number v-model="table2.temp.bzthreemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  266. </el-form-item>
  267. </el-col>
  268. <el-col :span="10">
  269. <el-form-item label="宾州筛第四层(%):">
  270. <el-input-number v-model="table2.temp.bzfourmin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  271. <span style="width: 1%;">-</span>
  272. <el-input-number v-model="table2.temp.bzfourmax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  273. </el-form-item>
  274. </el-col>
  275. </el-row>
  276. <el-row>
  277. <el-col :span="10">
  278. <el-form-item label="数据来源:" prop="bzsource">
  279. <el-input v-model="table2.temp.bzsource" type="textarea" placeholder="1-255字符" :autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
  280. </el-form-item>
  281. </el-col>
  282. </el-row>
  283. <el-row>
  284. <el-col :span="10">
  285. <h3 style="width: 160px;float: left;">粪便筛</h3>
  286. </el-col>
  287. </el-row>
  288. <el-row>
  289. <el-col :span="10">
  290. <el-form-item label="粪便筛第一层(%):">
  291. <el-input-number v-model="table2.temp.fbonemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  292. <span style="width: 1%;">-</span>
  293. <el-input-number v-model="table2.temp.fbonemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  294. </el-form-item>
  295. </el-col>
  296. <el-col :span="10">
  297. <el-form-item label="粪便筛第二层(%):">
  298. <el-input-number v-model="table2.temp.fbtwomin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  299. <span style="width: 1%;">-</span>
  300. <el-input-number v-model="table2.temp.fbtwomax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  301. </el-form-item>
  302. </el-col>
  303. </el-row>
  304. <el-row>
  305. <el-col :span="10">
  306. <el-form-item label="粪便筛第三层(%):">
  307. <el-input-number v-model="table2.temp.fbthreemin" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最小值" />
  308. <span style="width: 1%;">-</span>
  309. <el-input-number v-model="table2.temp.fbthreemax" :min="0" :max="100" :controls="false" style="width:44%;" placeholder="最大值" />
  310. </el-form-item>
  311. </el-col>
  312. <el-col :span="10">
  313. <el-form-item label="数据来源:" prop="fbsource">
  314. <el-input v-model="table2.temp.fbsource" type="textarea" placeholder="1-255字符" :autosize="{ minRows: 1, maxRows: 4}" style="width:100%;" maxlength="255" />
  315. </el-form-item>
  316. </el-col>
  317. </el-row>
  318. </el-form>
  319. <div slot="footer" class="dialog-footer">
  320. <el-button class="cancelClose" @click="table2.dialogFormVisible = false; getList2()">关闭</el-button>
  321. <el-button class="success" :disabled="isokDisable" @click="updateData()">确认</el-button>
  322. </div>
  323. </div>
  324. </el-dialog>
  325. </div>
  326. </template>
  327. <script>
  328. import { GetDataByName, PostDataByName, failproccess, GetDataByNames, checkButtons } from '@/api/common'
  329. import Cookies from 'js-cookie'
  330. import axios from 'axios'
  331. import { parseTime, json2excel } from '@/utils/index.js'
  332. import { getToken } from '@/utils/auth'
  333. export default {
  334. name: 'StandardParameters',
  335. data() {
  336. return {
  337. isRoleEdit: [],
  338. activeName: 'first',
  339. requestParams: [
  340. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['评分标准'] },
  341. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['粪便评分标准'] }
  342. ],
  343. physicalList: [], // 标准体况评分
  344. faecesList: [], // 标准粪便评分
  345. table1: {
  346. getdataListParm: {
  347. name: 'getOptscoreList',
  348. page: 1,
  349. offset: 1,
  350. returntype: 'Map',
  351. parammaps: {
  352. pastureid: Cookies.get('pastureid'),
  353. enable: ''
  354. }
  355. },
  356. tableKey: 0,
  357. list: [],
  358. total: 0,
  359. listLoading: true,
  360. // 编辑
  361. dialogFormVisible: false,
  362. dialogStatus: '',
  363. temp: {},
  364. rules: {
  365. bodystandard: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  366. dungstandard: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  367. }
  368. },
  369. table2: {
  370. getdataListParm: {
  371. name: 'getOptrangeList',
  372. page: 1,
  373. offset: 1,
  374. returntype: 'Map',
  375. parammaps: {
  376. pastureid: Cookies.get('pastureid')
  377. }
  378. },
  379. tableKey: 0,
  380. list: [],
  381. total: 0,
  382. listLoading: true,
  383. // 编辑
  384. dialogFormVisible: false,
  385. dialogStatus: '',
  386. temp: {},
  387. rules: {}
  388. },
  389. download: {
  390. getdataListParm: {},
  391. list: []
  392. },
  393. textMap: {
  394. update: '编辑'
  395. },
  396. requestParam: {},
  397. isokDisable: false,
  398. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  399. cellStyle: { padding: 0 + 'px' }
  400. }
  401. },
  402. computed: {
  403. // 设置请求头
  404. headers() {
  405. return {
  406. token: getToken()
  407. }
  408. },
  409. uploadData() {
  410. return {
  411. name: 'checkft,updateOptscoreUpload',
  412. importParams: '配方名称,体况评分标准(分),体况评分数据来源,粪便评分标准(分),粪便评分数据来源',
  413. sheetname: 'Sheet1',
  414. // 登录牧场
  415. pastureid: Cookies.get('pastureid'),
  416. // 日期参数
  417. dateParams: '',
  418. // 必填参数
  419. requiredParams: '配方名称,体况评分标准(分),粪便评分标准(分)',
  420. // 为数值的参数
  421. numParams: '体况评分标准(分),粪便评分标准(分)'
  422. }
  423. },
  424. // 设置上传地址
  425. uploadExcelUrl() {
  426. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  427. },
  428. headers2() {
  429. return {
  430. token: getToken()
  431. }
  432. },
  433. uploadData2() {
  434. return {
  435. name: 'checkbigcowclassW,checkclassnameW,insertOptrangeUpload',
  436. importParams: '牲畜父类,牲畜子类,宾州筛第一层(%),宾州筛第二层(%),宾州筛第三层(%),宾州筛第四层(%),宾州筛数据来源,粪便筛第一层(%),粪便筛第二层(%),粪便筛第三层(%),粪便筛数据来源',
  437. sheetname: 'Sheet1',
  438. // 登录牧场
  439. pastureid: Cookies.get('pastureid'),
  440. // 日期参数
  441. dateParams: '',
  442. // 必填参数
  443. requiredParams: '牲畜父类,牲畜子类',
  444. // 为数值的参数
  445. numParams: ''
  446. }
  447. },
  448. // 设置上传地址
  449. uploadExcelUrl2() {
  450. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  451. }
  452. },
  453. created() {
  454. this.getList()
  455. this.getDownList()
  456. this.getButtons()
  457. },
  458. methods: {
  459. getButtons() {
  460. const Edit = 'StandardParameters'
  461. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  462. this.isRoleEdit = isRoleEdit
  463. },
  464. getDownList() {
  465. GetDataByNames(this.requestParams).then(response => {
  466. this.physicalList = response.data.getDictByName.list
  467. this.faecesList = response.data.getDictByName2.list
  468. })
  469. },
  470. handleTabClick(tab, event) {
  471. console.log(tab, event)
  472. if (tab.name === 'first') {
  473. this.getList()
  474. } else if (tab.name === 'second') {
  475. this.getList2()
  476. }
  477. },
  478. getList() {
  479. this.table1.listLoading = true
  480. GetDataByName(this.table1.getdataListParm).then(response => {
  481. console.log('table1数据', response.data.list)
  482. if (response.data.list !== null) {
  483. this.table1.list = response.data.list
  484. this.table1.total = response.data.total
  485. } else {
  486. this.table1.list = []
  487. }
  488. setTimeout(() => {
  489. this.table1.listLoading = false
  490. }, 100)
  491. })
  492. },
  493. getList2() {
  494. this.table2.listLoading = true
  495. GetDataByName(this.table2.getdataListParm).then(response => {
  496. console.log('table1数据', response.data.list)
  497. if (response.data.list !== null) {
  498. this.table2.list = response.data.list
  499. if (response.data.total) {
  500. this.table2.total = response.data.total
  501. }
  502. } else {
  503. this.table2.list = []
  504. }
  505. setTimeout(() => {
  506. this.table2.listLoading = false
  507. }, 100)
  508. })
  509. },
  510. // 编辑
  511. handleUpdate(row) {
  512. if (this.activeName === 'first') {
  513. console.log('点击了体况、粪便评分标准编辑')
  514. this.table1.dialogStatus = 'update'
  515. this.table1.dialogFormVisible = true
  516. this.table1.temp = Object.assign({}, row)
  517. } else if (this.activeName === 'second') {
  518. console.log('点击了宾州筛、粪便筛标准范围编辑')
  519. this.table2.dialogStatus = 'update'
  520. this.table2.dialogFormVisible = true
  521. this.table2.temp = Object.assign({}, row)
  522. }
  523. },
  524. updateData() {
  525. if (this.activeName === 'first') {
  526. console.log('点击了体况、粪便评分标准编辑保存')
  527. this.isokDisable = true
  528. setTimeout(() => {
  529. this.isokDisable = false
  530. }, 1000)
  531. this.$refs['temp'].validate(valid => {
  532. if (valid) {
  533. this.requestParam.name = 'updateOptscore'
  534. this.requestParam.parammaps = this.table1.temp
  535. PostDataByName(this.requestParam).then(response => {
  536. console.log('新增保存发送参数', this.requestParam)
  537. if (response.msg !== 'fail') {
  538. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  539. this.table1.dialogFormVisible = false
  540. this.getList()
  541. } else {
  542. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  543. }
  544. })
  545. }
  546. })
  547. } else if (this.activeName === 'second') {
  548. console.log('点击了宾州筛、粪便筛标准范围编辑保存')
  549. this.isokDisable = true
  550. setTimeout(() => {
  551. this.isokDisable = false
  552. }, 1000)
  553. // 若最小值大于最大值
  554. if (parseFloat(this.table2.temp.bzonemin) > parseFloat(this.table2.temp.bzonemax)) {
  555. this.$message({ type: 'error', message: '宾州筛第一层最大值不可小于等于最小值', duration: 2000 })
  556. return false
  557. }
  558. if (parseFloat(this.table2.temp.bztwomin) > parseFloat(this.table2.temp.bztwomax)) {
  559. this.$message({ type: 'error', message: '宾州筛第二层最大值不可小于等于最小值', duration: 2000 })
  560. return false
  561. }
  562. if (parseFloat(this.table2.temp.bzthreemin) > parseFloat(this.table2.temp.bzthreemax)) {
  563. this.$message({ type: 'error', message: '宾州筛第三层最大值不可小于等于最小值', duration: 2000 })
  564. return false
  565. }
  566. if (parseFloat(this.table2.temp.bzfourmin) > parseFloat(this.table2.temp.bzfourmax)) {
  567. this.$message({ type: 'error', message: '宾州筛第四层最大值不可小于等于最小值', duration: 2000 })
  568. return false
  569. }
  570. if (parseFloat(this.table2.temp.fbonemin) > parseFloat(this.table2.temp.fbonemax)) {
  571. this.$message({ type: 'error', message: '粪便筛第一层最大值不可小于等于最小值', duration: 2000 })
  572. return false
  573. }
  574. if (parseFloat(this.table2.temp.fbtwomin) > parseFloat(this.table2.temp.fbtwomax)) {
  575. this.$message({ type: 'error', message: '粪便筛第二层最大值不可小于等于最小值', duration: 2000 })
  576. return false
  577. }
  578. if (parseFloat(this.table2.temp.fbthreemin) > parseFloat(this.table2.temp.fbthreemax)) {
  579. this.$message({ type: 'error', message: '粪便筛第三层最大值不可小于等于最小值', duration: 2000 })
  580. return false
  581. }
  582. // 若最大值最小值为空
  583. if (this.table2.temp.bzonemin == '' || this.table2.temp.bzonemin == undefined) { this.table2.temp.bzonemin = '0' }
  584. if (this.table2.temp.bzonemax == '' || this.table2.temp.bzonemax == undefined) { this.table2.temp.bzonemax = '0' }
  585. if (this.table2.temp.bztwomin == '' || this.table2.temp.bztwomin == undefined) { this.table2.temp.bztwomin = '0' }
  586. if (this.table2.temp.bztwomax == '' || this.table2.temp.bztwomax == undefined) { this.table2.temp.bztwomax = '0' }
  587. if (this.table2.temp.bzthreemin == '' || this.table2.temp.bzthreemin == undefined) { this.table2.temp.bzthreemin = '0' }
  588. if (this.table2.temp.bzthreemax == '' || this.table2.temp.bzthreemax == undefined) { this.table2.temp.bzthreemax = '0' }
  589. if (this.table2.temp.bzfourmin == '' || this.table2.temp.bzfourmin == undefined) { this.table2.temp.bzfourmin = '0' }
  590. if (this.table2.temp.bzfourmax == '' || this.table2.temp.bzfourmax == undefined) { this.table2.temp.bzfourmax = '0' }
  591. if (this.table2.temp.fbonemin == '' || this.table2.temp.fbonemin == undefined) { this.table2.temp.fbonemin = '0' }
  592. if (this.table2.temp.fbonemax == '' || this.table2.temp.fbonemax == undefined) { this.table2.temp.fbonemax = '0' }
  593. if (this.table2.temp.fbtwomin == '' || this.table2.temp.fbtwomin == undefined) { this.table2.temp.fbtwomin = '0' }
  594. if (this.table2.temp.fbtwomax == '' || this.table2.temp.fbtwomax == undefined) { this.table2.temp.fbtwomax = '0' }
  595. if (this.table2.temp.fbthreemin == '' || this.table2.temp.fbthreemin == undefined) { this.table2.temp.fbthreemin = '0' }
  596. if (this.table2.temp.fbthreemax == '' || this.table2.temp.fbthreemax == undefined) { this.table2.temp.fbthreemax = '0' }
  597. var positiveInteger = /^([0-9]{1,2}|100)$/
  598. if (!positiveInteger.test(parseFloat(this.table2.temp.bzonemin))) {
  599. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  600. return false
  601. }
  602. if (!positiveInteger.test(parseFloat(this.table2.temp.bzonemax))) {
  603. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  604. return false
  605. }
  606. if (!positiveInteger.test(parseFloat(this.table2.temp.bztwomin))) {
  607. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  608. return false
  609. }
  610. if (!positiveInteger.test(parseFloat(this.table2.temp.bztwomax))) {
  611. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  612. return false
  613. }
  614. if (!positiveInteger.test(parseFloat(this.table2.temp.bzthreemin))) {
  615. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  616. return false
  617. }
  618. if (!positiveInteger.test(parseFloat(this.table2.temp.bzthreemax))) {
  619. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  620. return false
  621. }
  622. if (!positiveInteger.test(parseFloat(this.table2.temp.bzfourmin))) {
  623. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  624. return false
  625. }
  626. if (!positiveInteger.test(parseFloat(this.table2.temp.bzfourmax))) {
  627. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  628. return false
  629. }
  630. if (!positiveInteger.test(parseFloat(this.table2.temp.fbonemin))) {
  631. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  632. return false
  633. }
  634. if (!positiveInteger.test(parseFloat(this.table2.temp.fbonemax))) {
  635. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  636. return false
  637. }
  638. if (!positiveInteger.test(parseFloat(this.table2.temp.fbtwomin))) {
  639. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  640. return false
  641. }
  642. if (!positiveInteger.test(parseFloat(this.table2.temp.fbtwomax))) {
  643. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  644. return false
  645. }
  646. if (!positiveInteger.test(parseFloat(this.table2.temp.fbthreemin))) {
  647. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  648. return false
  649. }
  650. if (!positiveInteger.test(parseFloat(this.table2.temp.fbthreemin))) {
  651. this.$message({ type: 'error', message: '范围不可输入小数', duration: 2000 })
  652. return false
  653. }
  654. this.requestParam.name = 'insertOptrange'
  655. this.requestParam.parammaps = this.table2.temp
  656. this.$refs['temp'].validate(valid => {
  657. if (valid) {
  658. PostDataByName(this.requestParam).then(response => {
  659. console.log('新增保存发送参数', this.requestParam)
  660. if (response.msg !== 'fail') {
  661. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  662. this.table2.dialogFormVisible = false
  663. this.getList2()
  664. this.activeName = 'second'
  665. } else {
  666. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  667. if (this.table2.temp.bzonemin == '0') { this.table2.temp.bzonemin = '' }
  668. if (this.table2.temp.bzonemax == '0') { this.table2.temp.bzonemax = '' }
  669. if (this.table2.temp.bztwomin == '0') { this.table2.temp.bztwomin = '' }
  670. if (this.table2.temp.bztwomax == '0') { this.table2.temp.bztwomax = '' }
  671. if (this.table2.temp.bzthreemin == '0') { this.table2.temp.bzthreemin = '' }
  672. if (this.table2.temp.bzthreemax == '0') { this.table2.temp.bzthreemax = '' }
  673. if (this.table2.temp.bzfourmin == '0') { this.table2.temp.bzfourmin = '' }
  674. if (this.table2.temp.bzfourmax == '0') { this.table2.temp.bzfourmax = '' }
  675. if (this.table2.temp.fbonemin == '0') { this.table2.temp.fbonemin = '' }
  676. if (this.table2.temp.fbonemax == '0') { this.table2.temp.fbonemax = '' }
  677. if (this.table2.temp.fbtwomin == '0') { this.table2.temp.fbtwomin = '' }
  678. if (this.table2.temp.fbtwomax == '0') { this.table2.temp.fbtwomax = '' }
  679. if (this.table2.temp.fbthreemin == '0') { this.table2.temp.fbthreemin = '' }
  680. if (this.table2.temp.fbthreemax == '0') { this.table2.temp.fbthreemax = '' }
  681. }
  682. })
  683. }
  684. })
  685. }
  686. },
  687. // 导出
  688. handleExport() {
  689. if (this.activeName === 'first') {
  690. console.log('体况、粪便评分标准/导出')
  691. this.download.getdataListParm.name = 'getOptrangeList'
  692. this.download.getdataListParm.parammaps = {}
  693. this.download.getdataListParm.parammaps.pastureid = Cookies.get('pastureid')
  694. GetDataByName(this.download.getdataListParm).then(response => {
  695. if (response.data.list !== null) {
  696. this.download.list = response.data.list
  697. } else {
  698. this.download.list = []
  699. }
  700. var downloadList = [
  701. { 'obj1': '1、文件类型为xlsx类型,对应表格文件名格式为:文件名称.xlsx;' },
  702. { 'obj1': '2、底部工作表名称不可更改,默认为:Sheet1;' },
  703. { 'obj1': '3、配方名称,体况评分标准(分),粪便评分标准为必填;' },
  704. { 'obj1': '4、配方名称必须与系统中配方模板的配方名称匹配;' },
  705. { 'obj1': '5、标准分数为固定几个分值,仅可下拉选择' },
  706. { 'obj1': '6、数据最多可导入200条,超过200条请分多个文件导入。' }
  707. ]
  708. var excelDatas = [
  709. {
  710. tHeader: ['配方名称', '体况评分标准(分)', '数据来源', '粪便评分标准', '数据来源'],
  711. filterVal: ['ftname', '', '', '', ''],
  712. tableDatas: this.download.list,
  713. sheetName: 'Sheet1'
  714. }, {
  715. tHeader: ['填写规范:'],
  716. filterVal: ['obj1'],
  717. tableDatas: downloadList,
  718. sheetName: 'Sheet2'
  719. }
  720. ]
  721. json2excel(excelDatas, '基础数据_体况、粪便评分标准导入模板', true, 'xlsx')
  722. })
  723. } else if (this.activeName === 'second') {
  724. console.log('宾州筛、粪便筛标准范围/导出')
  725. this.download.getdataListParm.name = 'getOptrangeList'
  726. this.download.getdataListParm.parammaps = {}
  727. this.download.getdataListParm.parammaps.pastureid = Cookies.get('pastureid')
  728. GetDataByName(this.download.getdataListParm).then(response => {
  729. if (response.data.list !== null) {
  730. this.download.list = response.data.list
  731. } else {
  732. this.download.list = []
  733. }
  734. var downloadList = [
  735. { 'obj1': '1、文件类型为xlsx类型,对应表格文件名格式为:文件名称.xlsx;' },
  736. { 'obj1': '2、底部工作表名称不可更改,默认为:Sheet1;' },
  737. { 'obj1': '3、牲畜父类,牲畜子类为必填;' },
  738. { 'obj1': '4、牲畜类别必须与系统基础数据中牲畜类别匹配;' },
  739. { 'obj1': '5、数据最多可导入200条,超过200条请分多个文件导入。' }
  740. ]
  741. var excelDatas = [
  742. {
  743. tHeader: ['牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '数据来源', '粪便筛筛一层(%)', '粪便筛筛二层(%)', '粪便筛筛三层(%)', '数据来源'],
  744. filterVal: ['parentname', 'cowname', '', '', '', '', '', '', '', '', ''],
  745. tableDatas: this.download.list,
  746. sheetName: 'Sheet1'
  747. }, {
  748. tHeader: ['填写规范:'],
  749. filterVal: ['obj1'],
  750. tableDatas: downloadList,
  751. sheetName: 'Sheet2'
  752. }
  753. ]
  754. json2excel(excelDatas, '基础数据_宾州筛、粪便筛标准范围导入模板', true, 'xlsx')
  755. })
  756. }
  757. },
  758. beforeImport(file) {
  759. const isLt2M = file.size / 1024 / 1024 < 2
  760. if (!isLt2M) {
  761. this.$message.error('上传文件大小不能超过 2MB!')
  762. }
  763. return isLt2M
  764. },
  765. handleImportSuccess(res, file) {
  766. this.getList()
  767. if (res.msg === 'ok') {
  768. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  769. if (res.data.err_count > 0) {
  770. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  771. import('@/vendor/Export2Excel').then(excel => {
  772. const list1 = res.data.result
  773. const tHeader = [
  774. '配方名称', '体况评分标准(分)', '体况评分数据来源', '粪便评分标准(分)', '粪便评分数据来源', '错误信息'
  775. ]
  776. const filterVal = [
  777. '配方名称', '体况评分标准(分)', '体况评分数据来源', '粪便评分标准(分)', '粪便评分数据来源', 'error_msg'
  778. ]
  779. const data1 = this.formatJson(filterVal, list1)
  780. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '宾州筛导入报错信息', autoWidth: true, bookType: 'xlsx' })
  781. })
  782. }
  783. } else {
  784. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  785. }
  786. },
  787. formatJson(filterVal, jsonData) {
  788. return jsonData.map(v =>
  789. filterVal.map(j => {
  790. if (j === 'timestamp') {
  791. return parseTime(v[j])
  792. } else {
  793. return v[j]
  794. }
  795. })
  796. )
  797. },
  798. beforeImport2(file) {
  799. const isLt2M = file.size / 1024 / 1024 < 2
  800. if (!isLt2M) {
  801. this.$message.error('上传文件大小不能超过 2MB!')
  802. }
  803. return isLt2M
  804. },
  805. handleImportSuccess2(res, file) {
  806. this.getList2()
  807. if (res.msg === 'ok') {
  808. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  809. if (res.data.err_count > 0) {
  810. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  811. import('@/vendor/Export2Excel').then(excel => {
  812. const list1 = res.data.result
  813. const tHeader = [
  814. '牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '宾州筛数据来源', '粪便筛第二层(%)', '粪便筛第三层(%)', '粪便筛数据来源', '错误信息'
  815. ]
  816. const filterVal = [
  817. '牲畜父类', '牲畜子类', '宾州筛一层(%)', '宾州筛二层(%)', '宾州筛三层(%)', '宾州筛四层(%)', '宾州筛数据来源', '粪便筛第二层(%)', '粪便筛第三层(%)', '粪便筛数据来源', 'error_msg'
  818. ]
  819. const data1 = this.formatJson2(filterVal, list1)
  820. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '宾州筛导入报错信息', autoWidth: true, bookType: 'xlsx' })
  821. })
  822. }
  823. } else {
  824. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  825. }
  826. },
  827. formatJson2(filterVal, jsonData) {
  828. return jsonData.map(v =>
  829. filterVal.map(j => {
  830. if (j === 'timestamp') {
  831. return parseTime(v[j])
  832. } else {
  833. return v[j]
  834. }
  835. })
  836. )
  837. }
  838. // 导入
  839. // handleImport() {
  840. // if (this.activeName === 'first') {
  841. // console.log('体况、粪便评分标准/导入')
  842. // } else if (this.activeName === 'second') {
  843. // console.log('宾州筛、粪便筛标准范围/导入')
  844. // }
  845. // }
  846. }
  847. }
  848. </script>
  849. <style lang="scss" scoped>
  850. .operation{
  851. position: relative;
  852. height: 50px;
  853. .export{position: absolute;right: 110px;bottom: 10px;}
  854. .import{position: absolute;right: 0;bottom: 10px;}
  855. }
  856. </style>