d626305d82a7470be1b08df520a6668ed2662f4b.svn-base 45 KB

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