3e437b4a6beafb228c78b448a407cc59d565e4e9.svn-base 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-input v-model="table.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  5. <el-select v-model="table.getdataListParm.parammaps.fclassid" filterable placeholder="饲料类别" class="filter-item" style="width: 150px;" clearable>
  6. <el-option v-for="item in feedTypeList" :key="item.id" :label="item.mixname" :value="item.id" />
  7. </el-select>
  8. <el-select v-model="table.getdataListParm.parammaps.source" filterable placeholder="饲料来源" class="filter-item" style="width: 120px;" clearable>
  9. <el-option v-for="item in feedSourcesList" :key="item.id" :label="item.name" :value="item.id" />
  10. </el-select>
  11. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  12. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  13. </el-select>
  14. <div ref="selectInput" class="filter-item selectInput">
  15. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  16. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  17. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  18. <ul v-if="arrowUp" class="selectUl">
  19. <li><a>允许误差数</a><el-input v-model="table.getdataListParm.parammaps.allowratio"type="text" style="width: 245px;" /></li>
  20. <li><a>跳转重量域</a><el-input v-model="table.getdataListParm.parammaps.autozone" type="text" style="width: 245px;" /></li>
  21. <li>
  22. <a>跳转延时</a>
  23. <el-select v-model="table.getdataListParm.parammaps.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width: 245px;" clearable>
  24. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  25. </el-select>
  26. </li>
  27. <li>
  28. <div style="float: right;">
  29. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  30. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  31. </div>
  32. </li>
  33. </ul>
  34. </div>
  35. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  36. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  37. </div>
  38. <div class="operation">
  39. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">新增</el-button>
  40. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
  41. <el-button class="success" icon="el-icon-receiving" @click="handleFeedBank">饲料库</el-button>
  42. </div>
  43. <div class="table">
  44. <el-table
  45. :key="table.tableKey"
  46. v-loading="table.listLoading"
  47. element-loading-text="给我一点时间"
  48. :data="table.list"
  49. border
  50. fit
  51. highlight-current-row
  52. style="width: 100%;"
  53. :row-style="rowStyle"
  54. :cell-style="cellStyle"
  55. class="elTable table-fixed"
  56. @selection-change="handleSelectionChange"
  57. >
  58. <el-table-column type="selection" align="center" width="50" fixed="left" />
  59. <el-table-column label="序号" align="center" type="index" width="50px" fixed="left">
  60. <template slot-scope="scope">
  61. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="饲料名称" min-width="80px" align="center" fixed="left">
  65. <template slot-scope="scope">
  66. <span>{{ scope.row.fname }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="饲料分类" min-width="80px" align="center" fixed="left">
  70. <template slot-scope="scope">
  71. <span>{{ scope.row.fclass }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="唯一编码" min-width="80px" align="center">
  75. <template slot-scope="scope">
  76. <span>{{ scope.row.feedcode }}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="饲料来源" min-width="80px" align="center">
  80. <template slot-scope="scope">
  81. <span>{{ scope.row.source }}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="计划类型" min-width="90px" align="center">
  85. <template slot-scope="scope">
  86. <span>{{ scope.row.printgroup }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="小料秤" min-width="90px" align="center">
  90. <template slot-scope="scope">
  91. <span>{{ scope.row.smtmrname }}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="允许误差数(kg)" min-width="85px" align="center">
  95. <template slot-scope="scope">
  96. <span>{{ scope.row.allowratio }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="包装单位重量(kg)" min-width="80px" align="center">
  100. <template slot-scope="scope">
  101. <span>{{ scope.row.unitweight }}</span>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="单价" min-width="50px" align="center">
  105. <template slot-scope="scope">
  106. <span>{{ scope.row.uprice }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="跳转重量域(kg)" min-width="90px" align="center">
  110. <template slot-scope="scope">
  111. <span>{{ scope.row.autozone }}</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="跳转延时" min-width="80px" align="center">
  115. <template slot-scope="scope">
  116. <span>{{ scope.row.autosecondname }}</span>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="确认开始" min-width="80px" align="center">
  120. <template slot-scope="scope">
  121. <span>{{ scope.row.confirmstartname }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="继电器位置" min-width="60px" align="center">
  125. <template slot-scope="scope">
  126. <span>{{ scope.row.trgaddress }}</span>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="无上域" min-width="60px" align="center">
  130. <template slot-scope="scope">
  131. <span v-if="scope.row.jmp == 0">否</span>
  132. <span v-else>是</span>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="备用字段01" min-width="90px" align="center">
  136. <template slot-scope="scope">
  137. <span>{{ scope.row.backup1 }}</span>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="备用字段02" min-width="90px" align="center">
  141. <template slot-scope="scope">
  142. <span>{{ scope.row.backup2 }}</span>
  143. </template>
  144. </el-table-column>
  145. <el-table-column label="备用字段03" min-width="90px" align="center">
  146. <template slot-scope="scope">
  147. <span>{{ scope.row.backup3 }}</span>
  148. </template>
  149. </el-table-column>
  150. <el-table-column label="是否启用" min-width="80px" align="center">
  151. <template slot-scope="scope">
  152. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width" fixed="right">
  156. <template slot-scope="{row}">
  157. <a class="correcting" @click="handleNutritive (row)">营养价值</a>
  158. <span class="centerSpan">|</span>
  159. <a v-if="isRoleEdit" class="correcting" @click="handleRelation(row)">关联</a>
  160. <span v-if="isRoleEdit" class="centerSpan">|</span>
  161. <el-button v-if="isRoleEdit" icon="el-icon-edit-outline" class="miniSuccess" @click="handleUpdate(row)" />
  162. <span v-if="isRoleEdit" class="centerSpan">|</span>
  163. <el-button v-if="isRoleEdit" icon="el-icon-delete" class="miniDanger" @click="handleRowDelete(row)" />
  164. </template>
  165. </el-table-column>
  166. </el-table>
  167. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  168. </div>
  169. <!-- 新增/编辑 -->
  170. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  171. <div class="app-add">
  172. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
  173. <el-row>
  174. <el-col :span="24">
  175. <h3 style="width: 160px;text-align: right;">基础信息</h3>
  176. </el-col>
  177. </el-row>
  178. <el-row>
  179. <el-col :span="6">
  180. <el-form-item label="饲料名称:" prop="fname">
  181. <el-input ref="fname" v-model="create.temp.fname" class="filter-item" placeholder="请输入饲料名称" type="textarea" :autosize="{ minRows:1}" maxlength="32" />
  182. </el-form-item>
  183. </el-col>
  184. <el-col :span="6">
  185. <el-form-item label="饲料类别:" prop="fclassid">
  186. <el-select v-model="create.temp.fclassid" filterable placeholder="饲料类别" class="filter-item" style="width: 100%;" @change="changeFeedList">
  187. <el-option v-for="item in feedTypeList" :key="item.id" :label="item.mixname" :value="item.id" />
  188. </el-select>
  189. </el-form-item></el-col>
  190. <el-col :span="6">
  191. <el-form-item label="唯一编码:" prop="feedcode">
  192. <el-input ref="feedcode" v-model="create.temp.feedcode" class="filter-item" placeholder="请输入唯一编码" type="text" />
  193. </el-form-item>
  194. </el-col>
  195. <el-col :span="6">
  196. <el-form-item label="饲料来源:" prop="source">
  197. <el-input ref="source" v-model="create.temp.source" class="filter-item" disabled placeholder="用户自定义" type="text" />
  198. </el-form-item>
  199. </el-col>
  200. </el-row>
  201. <el-row>
  202. <el-col :span="6">
  203. <el-form-item label="计划类型:" prop="printgroupid">
  204. <el-select v-model="create.temp.printgroupid" filterable placeholder="计划类型" class="filter-item" style="width: 100%;" @change="changePlanList">
  205. <el-option v-for="item in planTypeList" :key="item.value" :label="item.label" :value="item.value" />
  206. </el-select>
  207. </el-form-item>
  208. </el-col>
  209. <el-col :span="6">
  210. <el-form-item label="包装单位重量(kg):" prop="unitweight">
  211. <el-input ref="unitweight" v-model="create.temp.unitweight" class="filter-item" placeholder="正整数" type="number" style="width: 100%;" />
  212. </el-form-item>
  213. </el-col>
  214. <el-col :span="6">
  215. <el-form-item label="单价:" prop="uprice">
  216. <el-input ref="uprice" v-model="create.temp.uprice" v-limit class="filter-item" placeholder="最多俩位小数" type="number" step="0.01" style="width: 100%;" />
  217. </el-form-item>
  218. </el-col>
  219. </el-row>
  220. <el-row>
  221. <el-col :span="24">
  222. <h3 style="width: 160px;text-align: right;">搅拌参数</h3>
  223. </el-col>
  224. </el-row>
  225. <el-row>
  226. <el-col :span="6">
  227. <el-form-item label="允许误差数(kg):" prop="allowratio">
  228. <el-input ref="allowratio" v-model="create.temp.allowratio" class="filter-item" placeholder="正整数" type="text" />
  229. </el-form-item>
  230. </el-col>
  231. <el-col :span="6">
  232. <el-form-item label="跳转重量域(kg):" prop="autozone">
  233. <el-input ref="autozone" v-model="create.temp.autozone" :disabled="create.temp.autosecond=='0'" class="filter-item" placeholder="0-50之间的整数" type="text" />
  234. </el-form-item>
  235. </el-col>
  236. <el-col :span="6">
  237. <el-form-item label="跳转延时:" prop="autosecond">
  238. <el-select v-model="create.temp.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width: 100%;" @change="changeAutosecond">
  239. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  240. </el-select>
  241. </el-form-item>
  242. </el-col>
  243. <el-col :span="6">
  244. <el-form-item label="确认开始:" prop="confirmstart">
  245. <el-select v-model="create.temp.confirmstart" filterabler placeholde="确认开始" class="filter-item" style="width: 100%;" @change="changeConfirmstart">
  246. <el-option v-for="item in confirmStartList" :key="item.id" :label="item.name" :value="item.id" />
  247. </el-select>
  248. </el-form-item>
  249. </el-col>
  250. </el-row>
  251. <el-row>
  252. <el-col :span="6">
  253. <el-form-item label="是否启用:" prop="enable">
  254. <el-select v-model="create.temp.enable" filterable placeholder="是否启用" class="filter-item" style="width: 100%;">
  255. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  256. </el-select>
  257. </el-form-item>
  258. </el-col>
  259. <el-col :span="6">
  260. <el-form-item label="继电器位置:" prop="trgaddress">
  261. <el-input ref="trgaddress" v-model="create.temp.trgaddress" class="filter-item" placeholder="继电器位置" type="number" />
  262. </el-form-item>
  263. </el-col>
  264. <el-col :span="6">
  265. <el-form-item label="小料秤:" prop="smtmrid">
  266. <el-select v-model="create.temp.smtmrid" filterable placeholder="小料秤" clearable class="filter-item" style="width: 100%;" @change="changeSmallMaterial">
  267. <el-option v-for="item in smallMaterialList" :key="item.id" :label="item.tname" :value="item.id" />
  268. </el-select>
  269. </el-form-item>
  270. </el-col>
  271. <el-col :span="6">
  272. <el-form-item label="无上域:" prop="jmp">
  273. <el-select v-model="create.temp.jmp" placeholder="无上域" class="filter-item" style="width: 100%;" @change="changeSmallMaterial">
  274. <el-option v-for="item in jmpList" :key="item.id" :label="item.name" :value="item.id" />
  275. </el-select>
  276. </el-form-item>
  277. </el-col>
  278. </el-row>
  279. <el-row>
  280. <h3 style="width: 160px;text-align: right;">备用字段</h3>
  281. </el-row>
  282. <el-row>
  283. <el-col :span="6">
  284. <el-form-item label="备用字段01:" prop="backup1">
  285. <el-input ref="backup1" v-model="create.temp.backup1" class="filter-item" placeholder="备用字段01" type="text" />
  286. </el-form-item>
  287. </el-col>
  288. <el-col :span="6">
  289. <el-form-item label="备用字段02:" prop="backup2">
  290. <el-input ref="backup2" v-model="create.temp.backup2" class="filter-item" placeholder="备用字段02" type="text" />
  291. </el-form-item>
  292. </el-col>
  293. <el-col :span="6">
  294. <el-form-item label="备用字段03:" prop="backup3">
  295. <el-input ref="backup3" v-model="create.temp.backup3" class="filter-item" placeholder="备用字段03" type="text" />
  296. </el-form-item>
  297. </el-col>
  298. </el-row>
  299. </el-form>
  300. <div slot="footer" class="dialog-footer">
  301. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  302. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="save" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  303. </div>
  304. </div>
  305. </el-dialog>
  306. <!-- 饲料库 -->
  307. <el-dialog :title="textMap[feedBank.dialogStatus]" :visible.sync="feedBank.dialogFormVisible" :close-on-click-modal="false" width="90%">
  308. <div class="app-add">
  309. <div class="search">
  310. <el-input v-model="feedBank.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  311. <el-select v-model="feedBank.getdataListParm.parammaps.statue" filterabler placeholder="关联状态" class="filter-item" style="width: 120px;" clearable>
  312. <el-option v-for="item in associationStatusList" :key="item.id" :label="item.name" :value="item.id" />
  313. </el-select>
  314. <el-button class="successBorder" @click="handleFeedBankSearch">查询</el-button>
  315. <el-button class="successBorder" @click="handleFeedBankRefresh">重置</el-button>
  316. </div>
  317. <div class="table">
  318. <el-table
  319. :key="feedBank.tableKey"
  320. v-loading="feedBank.listLoading"
  321. element-loading-text="给我一点时间"
  322. :data="feedBank.list"
  323. border
  324. fit
  325. highlight-current-row
  326. style="width: 100%;margin: 0 auto 50px;"
  327. :row-style="rowStyle"
  328. :cell-style="cellStyle"
  329. class="elTable table-fixed"
  330. >
  331. <el-table-column label="序号" align="center" type="index" width="50px" />
  332. <el-table-column label="来源" min-width="50" align="center">
  333. <template slot-scope="scope">
  334. <span>{{ scope.row.sources }}</span>
  335. </template>
  336. </el-table-column>
  337. <el-table-column label="中国饲料号" min-width="70px" align="center">
  338. <template slot-scope="scope">
  339. <span>{{ scope.row.feedcode }}</span>
  340. </template>
  341. </el-table-column>
  342. <el-table-column label="饲料名称" min-width="80px" align="center">
  343. <template slot-scope="scope">
  344. <span>{{ scope.row.fname }}</span>
  345. </template>
  346. </el-table-column>
  347. <el-table-column label="价格" min-width="50px" align="center">
  348. <template slot-scope="scope">
  349. <span>{{ scope.row.price }}</span>
  350. </template>
  351. </el-table-column>
  352. <el-table-column label="样品说明" min-width="50px" align="center">
  353. <template slot-scope="scope">
  354. <span>{{ scope.row.remark }}</span>
  355. </template>
  356. </el-table-column>
  357. <el-table-column label="干物质(DM%)" min-width="65px" align="center">
  358. <template slot-scope="scope">
  359. <span>{{ scope.row.dry }}</span>
  360. </template>
  361. </el-table-column>
  362. <el-table-column label="淀粉(%DM)" min-width="59px" align="center">
  363. <template slot-scope="scope">
  364. <span>{{ scope.row.starch }}</span>
  365. </template>
  366. </el-table-column>
  367. <el-table-column label="粗蛋白(CP%DM)" min-width="70px" align="center">
  368. <template slot-scope="scope">
  369. <span>{{ scope.row.cp }}</span>
  370. </template>
  371. </el-table-column>
  372. <el-table-column label="钙(Ca%DM)" min-width="85px" align="center">
  373. <template slot-scope="scope">
  374. <span>{{ scope.row.ca }}</span>
  375. </template>
  376. </el-table-column>
  377. <el-table-column label="磷(P%DM)" min-width="85px" align="center">
  378. <template slot-scope="scope">
  379. <span>{{ scope.row.p }}</span>
  380. </template>
  381. </el-table-column>
  382. <el-table-column label="产奶净能(%DM)" min-width="75px" align="center">
  383. <template slot-scope="scope">
  384. <span>{{ scope.row.n }}</span>
  385. </template>
  386. </el-table-column>
  387. <el-table-column label="脂肪(%DM)" min-width="59px" align="center">
  388. <template slot-scope="scope">
  389. <span>{{ scope.row.fat }}</span>
  390. </template>
  391. </el-table-column>
  392. <el-table-column label="ADF(%DM)" min-width="60px" align="center">
  393. <template slot-scope="scope">
  394. <span>{{ scope.row.adf }}</span>
  395. </template>
  396. </el-table-column>
  397. <el-table-column label="NDF(%DM)" min-width="60px" align="center">
  398. <template slot-scope="scope">
  399. <span>{{ scope.row.ndf }}</span>
  400. </template>
  401. </el-table-column>
  402. <el-table-column label="NDIP%" min-width="70px" align="center">
  403. <template slot-scope="scope">
  404. <span>{{ scope.row.ndip }}</span>
  405. </template>
  406. </el-table-column>
  407. <el-table-column label="粗灰分(Ash%)" min-width="65px" align="center">
  408. <template slot-scope="scope">
  409. <span>{{ scope.row.ash }}</span>
  410. </template>
  411. </el-table-column>
  412. <el-table-column label="粗料" min-width="50px" align="center">
  413. <template slot-scope="scope">
  414. <span>{{ scope.row.iscu }}</span>
  415. </template>
  416. </el-table-column>
  417. <el-table-column label="关联状态" min-width="50px" align="center">
  418. <template slot-scope="scope">
  419. <span v-if="scope.row.statue==0">否</span>
  420. <span v-if="scope.row.statue==1">是</span>
  421. </template>
  422. </el-table-column>
  423. </el-table>
  424. </div>
  425. <div slot="footer" class="dialog-footer">
  426. <el-button class="cancelClose cancelClose1" @click="feedBank.dialogFormVisible = false; ">关闭</el-button>
  427. </div>
  428. </div>
  429. </el-dialog>
  430. <!-- 关联 -->
  431. <el-dialog :title="textMap[relation.dialogStatus]" :visible.sync="relation.dialogFormVisible" :close-on-click-modal="false" width="90%">
  432. <div class="app-add">
  433. <div class="search">
  434. <el-input v-model="relation.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  435. <el-button class="successBorder" @click="handleRelationSearch">查询</el-button>
  436. </div>
  437. <div class="table">
  438. <el-table
  439. :key="relation.tableKey"
  440. v-loading="relation.listLoading"
  441. element-loading-text="给我一点时间"
  442. :data="relation.list"
  443. border
  444. fit
  445. highlight-current-row
  446. style="width: 100%;margin: 0 auto 50px;"
  447. :row-style="rowStyle"
  448. :cell-style="cellStyle"
  449. class="elTable table-fixed"
  450. >
  451. <el-table-column label="序号" align="center" type="index" width="50px" />
  452. <el-table-column label="来源" min-width="50" align="center">
  453. <template slot-scope="scope">
  454. <span>{{ scope.row.sources }}</span>
  455. </template>
  456. </el-table-column>
  457. <el-table-column label="中国饲料号" min-width="80px" align="center">
  458. <template slot-scope="scope">
  459. <span>{{ scope.row.feedcode }}</span>
  460. </template>
  461. </el-table-column>
  462. <el-table-column label="饲料名称" min-width="80px" align="center">
  463. <template slot-scope="scope">
  464. <span>{{ scope.row.fname }}</span>
  465. </template>
  466. </el-table-column>
  467. <el-table-column label="价格" min-width="50px" align="center">
  468. <template slot-scope="scope">
  469. <span>{{ scope.row.price }}</span>
  470. </template>
  471. </el-table-column>
  472. <el-table-column label="样品说明" min-width="50px" align="center">
  473. <template slot-scope="scope">
  474. <span>{{ scope.row.remark }}</span>
  475. </template>
  476. </el-table-column>
  477. <el-table-column label="干物质(DM%)" min-width="65px" align="center">
  478. <template slot-scope="scope">
  479. <span>{{ scope.row.dry }}</span>
  480. </template>
  481. </el-table-column>
  482. <el-table-column label="淀粉(%DM)" min-width="59px" align="center">
  483. <template slot-scope="scope">
  484. <span>{{ scope.row.starch }}</span>
  485. </template>
  486. </el-table-column>
  487. <el-table-column label="粗蛋白(CP%DM)" min-width="75px" align="center">
  488. <template slot-scope="scope">
  489. <span>{{ scope.row.cp }}</span>
  490. </template>
  491. </el-table-column>
  492. <el-table-column label="钙(Ca%DM)" min-width="83px" align="center">
  493. <template slot-scope="scope">
  494. <span>{{ scope.row.ca }}</span>
  495. </template>
  496. </el-table-column>
  497. <el-table-column label="磷(P%DM)" min-width="80px" align="center">
  498. <template slot-scope="scope">
  499. <span>{{ scope.row.p }}</span>
  500. </template>
  501. </el-table-column>
  502. <el-table-column label="产奶净能(%DM)" min-width="75px" align="center">
  503. <template slot-scope="scope">
  504. <span>{{ scope.row.n }}</span>
  505. </template>
  506. </el-table-column>
  507. <el-table-column label="脂肪(%DM)" min-width="59px" align="center">
  508. <template slot-scope="scope">
  509. <span>{{ scope.row.fat }}</span>
  510. </template>
  511. </el-table-column>
  512. <el-table-column label="ADF(%DM)" min-width="60px" align="center">
  513. <template slot-scope="scope">
  514. <span>{{ scope.row.adf }}</span>
  515. </template>
  516. </el-table-column>
  517. <el-table-column label="NDF(%DM)" min-width="60px" align="center">
  518. <template slot-scope="scope">
  519. <span>{{ scope.row.ndf }}</span>
  520. </template>
  521. </el-table-column>
  522. <el-table-column label="NDIP%" min-width="70px" align="center">
  523. <template slot-scope="scope">
  524. <span>{{ scope.row.ndip }}</span>
  525. </template>
  526. </el-table-column>
  527. <el-table-column label="粗灰分(Ash%)" min-width="65px" align="center">
  528. <template slot-scope="scope">
  529. <span>{{ scope.row.ash }}</span>
  530. </template>
  531. </el-table-column>
  532. <el-table-column label="粗料" min-width="50px" align="center">
  533. <template slot-scope="scope">
  534. <span>{{ scope.row.iscu }}</span>
  535. </template>
  536. </el-table-column>
  537. <el-table-column label="操作" min-width="50px" align="center" class-name="small-padding fixed-width" fixed="right">
  538. <template slot-scope="{row}">
  539. <a v-if="row.statueRelation == '1'" class="correcting" :disabled="isokDisable" @click="disassociateData(row)">取消关联</a>
  540. <a v-if="row.statueRelation == '0'" class="correcting" :disabled="isokDisable" @click="relationData(row)">关联</a>
  541. </template>
  542. </el-table-column>
  543. </el-table>
  544. </div>
  545. <div slot="footer" class="dialog-footer">
  546. <el-button class="cancelClose cancelClose1" @click="relation.dialogFormVisible = false;getList() ">关闭</el-button>
  547. </div>
  548. </div>
  549. </el-dialog>
  550. <!-- 营养价值 -->
  551. <el-dialog :title="textMap[nutritive.dialogStatus]" :visible.sync="nutritive.dialogFormVisible" :close-on-click-modal="false" width="90%">
  552. <div class="app-add">
  553. <el-form ref="temp" :rules="nutritive.rules" :model="nutritive.temp" label-position="right" label-width="160px" style="width: 100%;margin:0 auto 50px">
  554. <el-row>
  555. <el-col :span="6">
  556. <el-form-item label="干物质(DM%):" prop="dry">
  557. <el-input ref="dry" v-model="nutritive.temp.dry" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入干物质" type="number" step="0.01" />
  558. </el-form-item>
  559. </el-col>
  560. <el-col :span="6">
  561. <el-form-item label="淀粉(%DM):" prop="starch">
  562. <el-input ref="starch" v-model="nutritive.temp.starch" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入淀粉" type="number" step="0.01" />
  563. </el-form-item>
  564. </el-col>
  565. <el-col :span="6">
  566. <el-form-item label="粗蛋白(CP%DM):" prop="cp">
  567. <el-input ref="cp" v-model="nutritive.temp.cp" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入粗蛋白" type="number" step="0.01" />
  568. </el-form-item>
  569. </el-col>
  570. <el-col :span="6">
  571. <el-form-item label="钙(Ca%DM):" prop="ca">
  572. <el-input ref="ca" v-model="nutritive.temp.ca" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入钙" type="number" step="0.01" />
  573. </el-form-item>
  574. </el-col>
  575. </el-row>
  576. <el-row>
  577. <el-col :span="6">
  578. <el-form-item label="磷(P%DM):" prop="p">
  579. <el-input ref="p" v-model="nutritive.temp.p" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入磷" type="number" step="0.01" />
  580. </el-form-item>
  581. </el-col>
  582. <el-col :span="6">
  583. <el-form-item label="产奶净能(%DM):" prop="n">
  584. <el-input ref="n" v-model="nutritive.temp.n" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入产奶净能" type="number" step="0.01" />
  585. </el-form-item>
  586. </el-col>
  587. <el-col :span="6">
  588. <el-form-item label="脂肪(%DM):" prop="fat">
  589. <el-input ref="fat" v-model="nutritive.temp.fat" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入脂肪" type="number" step="0.01" />
  590. </el-form-item>
  591. </el-col>
  592. <el-col :span="6">
  593. <el-form-item label="ADF(%DM):" prop="adf">
  594. <el-input ref="adf" v-model="nutritive.temp.adf" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入ADF" type="number" step="0.01" />
  595. </el-form-item>
  596. </el-col>
  597. </el-row>
  598. <el-row>
  599. <el-col :span="6">
  600. <el-form-item label="NDF(%DM):" prop="ndf">
  601. <el-input ref="ndf" v-model="nutritive.temp.ndf" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入NDF" type="number" step="0.01" />
  602. </el-form-item>
  603. </el-col>
  604. <el-col :span="6">
  605. <el-form-item label="NDIP(%):" prop="ndip">
  606. <el-input ref="ndip" v-model="nutritive.temp.ndip" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入NDIP" type="number" step="0.01" />
  607. </el-form-item>
  608. </el-col>
  609. <el-col :span="6">
  610. <el-form-item label="粗灰分(Ash%):" prop="ash">
  611. <el-input ref="ash" v-model="nutritive.temp.ash" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入粗灰分" type="number" min="0.00" step="0.01" />
  612. </el-form-item>
  613. </el-col>
  614. </el-row>
  615. </el-form>
  616. <div slot="footer" class="dialog-footer">
  617. <el-button class="cancelClose" @click="nutritive.dialogFormVisible = false;getList()">关闭</el-button>
  618. <el-button v-if="nutritive.dialogStatus==='nutritive' && isRoleEdit" class="save" :disabled="isokDisable" @click="nutritiveData()">确认</el-button>
  619. </div>
  620. </div>
  621. </el-dialog>
  622. </div>
  623. </template>
  624. <script>
  625. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  626. import Cookies from 'js-cookie'
  627. import Pagination from '@/components/Pagination'
  628. import { MessageBox } from 'element-ui'
  629. export default {
  630. name: 'FeedTable',
  631. components: { Pagination },
  632. directives: {
  633. limit: {
  634. // 指令的定义
  635. update: function(el) {
  636. el.onkeypress = function(e) {
  637. var code = e.charCode
  638. if (code != 0) {
  639. if (!String.fromCharCode(code).match(/[0-9\.]/)) {
  640. return false
  641. }
  642. }
  643. }
  644. el.addEventListener('textInput', function(e) {
  645. e.target.value = e.target.value.replace(/[^0-9\.]/g, '')
  646. })
  647. el.onkeyup = function(e) {
  648. e.target.value = e.target.value.replace(/[^0-9\.]/g, '')
  649. }
  650. }
  651. }
  652. },
  653. data() {
  654. return {
  655. isRoleEdit: [],
  656. requestParams: [
  657. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['跳转延时'] },
  658. { name: 'getFeedclassByBig', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  659. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['计划类型'] },
  660. { name: 'getTMRListEnableTypeFeed', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid'), eqtype: '4' }}
  661. ],
  662. enableList: [{ id: '1', name: '是' }, { id: '0', name: '否' }], // 是否启用
  663. feedSourcesList: [{ id: '0', name: '系统内置' }, { id: '1', name: '用户自定义' }], // 饲料来源
  664. confirmStartList: [{ id: '0', name: '禁用' }, { id: '1', name: '启用' }], // 确认开始
  665. associationStatusList: [{ id: '1', name: '是' }, { id: '0', name: '否' }], // 关联状态
  666. jumpDelayList: [], // 跳转延时
  667. feedTypeList: [], // 饲料分类
  668. planTypeList: [], // 计划类型
  669. smallMaterialList: [], // 小料秤
  670. jmpList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 无上域
  671. table: {
  672. tableKey: 0,
  673. list: [],
  674. total: 0,
  675. listLoading: true,
  676. getdataListParm: {
  677. name: 'getFeedList',
  678. page: 1,
  679. offset: 1,
  680. pagecount: parseInt(Cookies.get('pageCount')),
  681. returntype: 'Map',
  682. parammaps: {
  683. pastureid: Cookies.get('pastureid'),
  684. fname: '',
  685. fclassid: '',
  686. source: '',
  687. autozone: '',
  688. autosecond: '',
  689. allowratio: '',
  690. printgroup: '',
  691. enable: ''
  692. }
  693. }
  694. },
  695. // 多项搜索显示隐藏
  696. arrowDown: true,
  697. arrowUp: false,
  698. // 新增/编辑
  699. create: {
  700. dialogFormVisible: false,
  701. dialogStatus: '',
  702. temp: { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '' },
  703. rules: {
  704. fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  705. fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  706. feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  707. }
  708. },
  709. // 饲料库
  710. feedBank: {
  711. dialogFormVisible: false,
  712. dialogStatus: '',
  713. temp: {},
  714. rules: {},
  715. tableKey: 0,
  716. list: [],
  717. total: 0,
  718. listLoading: true,
  719. getdataListParm: {
  720. name: 'getFeednurList',
  721. page: 1,
  722. offset: 1,
  723. returntype: 'Map',
  724. parammaps: {
  725. pastureid: Cookies.get('pastureid'),
  726. fname: '',
  727. statue: ''
  728. }
  729. }
  730. },
  731. // 关联
  732. relation: {
  733. dialogFormVisible: false,
  734. dialogStatus: '',
  735. temp: {},
  736. rules: {},
  737. tableKey: 0,
  738. list: [],
  739. total: 0,
  740. listLoading: true,
  741. getdataListParm: {
  742. name: 'getFeednurRelation',
  743. page: 1,
  744. offset: 1,
  745. returntype: 'Map',
  746. parammaps: {
  747. pastureid: Cookies.get('pastureid'),
  748. fname: ''
  749. }
  750. }
  751. },
  752. // 营养价值
  753. nutritive: {
  754. dialogFormVisible: false,
  755. dialogStatus: '',
  756. temp: {},
  757. rules: {}
  758. },
  759. textMap: {
  760. create: '新增',
  761. update: '编辑',
  762. feedBank: '饲料库',
  763. relation: '关联',
  764. nutritive: '营养价值'
  765. },
  766. isokDisable: false,
  767. selectList: [],
  768. requestParam: {},
  769. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  770. cellStyle: { padding: 0 + 'px' }
  771. }
  772. },
  773. mounted() {
  774. document.addEventListener('click', (e) => {
  775. if (this.$refs.selectInput !== undefined) {
  776. if (!this.$refs.selectInput.contains(e.target)) {
  777. this.arrowDown = true
  778. this.arrowUp = false
  779. } else {
  780. this.arrowDown = false
  781. this.arrowUp = true
  782. }
  783. }
  784. })
  785. },
  786. created() {
  787. this.getList()
  788. this.getDownList()
  789. this.getButtons()
  790. },
  791. methods: {
  792. getButtons() {
  793. const Edit = 'FeedTable'
  794. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  795. this.isRoleEdit = isRoleEdit
  796. },
  797. getDownList() {
  798. GetDataByNames(this.requestParams).then(response => {
  799. this.jumpDelayList = response.data.getDictByName.list
  800. this.feedTypeList = response.data.getFeedclassByBig.list
  801. this.planTypeList = response.data.getDictByName2.list
  802. this.smallMaterialList = response.data.getTMRListEnableTypeFeed.list
  803. })
  804. },
  805. getList() {
  806. this.table.listLoading = true
  807. GetDataByName(this.table.getdataListParm).then(response => {
  808. console.log('table数据', response.data.list)
  809. if (response.data.list !== null) {
  810. this.table.list = response.data.list
  811. this.table.pageNum = response.data.pageNum
  812. this.table.pageSize = response.data.pageSize
  813. this.table.total = response.data.total
  814. } else {
  815. this.table.list = []
  816. }
  817. setTimeout(() => {
  818. this.table.listLoading = false
  819. }, 100)
  820. })
  821. },
  822. handleSearch() {
  823. console.log('点击了查询')
  824. this.table.getdataListParm.offset = 1
  825. this.getList()
  826. this.arrowDown = true
  827. this.arrowUp = false
  828. },
  829. handleRefresh() {
  830. console.log('点击了重置')
  831. this.table.getdataListParm.parammaps.fname = ''
  832. this.table.getdataListParm.parammaps.fclassid = ''
  833. this.table.getdataListParm.parammaps.source = ''
  834. this.table.getdataListParm.parammaps.autozone = ''
  835. this.table.getdataListParm.parammaps.autosecond = ''
  836. this.table.getdataListParm.parammaps.allowratio = ''
  837. this.table.getdataListParm.parammaps.printgroup = ''
  838. this.table.getdataListParm.parammaps.enable = ''
  839. this.table.getdataListParm.offset = 1
  840. this.getList()
  841. },
  842. resetTemp() {
  843. this.create.temp = { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '', jmp: '0' }
  844. },
  845. // 计划类型
  846. changePlanList(item) {
  847. this.create.temp.printgroup = this.planTypeList.find(obj => obj.value === item).label
  848. },
  849. // 饲料类型
  850. changeFeedList(item) {
  851. this.create.temp.fclass = this.feedTypeList.find(obj => obj.id === item).mixname
  852. },
  853. // 跳转延时
  854. changeAutosecond(item) {
  855. this.create.temp.autosecondname = this.jumpDelayList.find(obj => obj.value === item).label
  856. },
  857. // 确认开始
  858. changeConfirmstart(item) {
  859. this.create.temp.confirmstartname = this.confirmStartList.find(obj => obj.id === item).name
  860. },
  861. changeSmallMaterial(item) {
  862. if (item !== '') {
  863. this.create.temp.smtmrname = this.smallMaterialList.find(obj => obj.id === item).tname
  864. } else {
  865. this.create.temp.smtmrname = ''
  866. }
  867. },
  868. // 新增
  869. handleCreate() {
  870. console.log('点击了新增')
  871. this.resetTemp()
  872. this.create.dialogStatus = 'create'
  873. this.create.dialogFormVisible = true
  874. },
  875. createData() {
  876. console.log('点击了新增保存')
  877. this.isokDisable = true
  878. setTimeout(() => {
  879. this.isokDisable = false
  880. }, 1000)
  881. this.$refs['temp'].validate(valid => {
  882. if (valid) {
  883. const unitweight = /^[1-9]\d*$/
  884. if (this.create.temp.unitweight !== '') {
  885. if (!unitweight.test(parseFloat(this.create.temp.unitweight))) {
  886. this.$message({ type: 'error', message: '包装单位重量请输入正整数', duration: 2000 })
  887. return false
  888. }
  889. }
  890. const uprice = /^\d+(\.\d{1,2})?$/
  891. if (this.create.temp.uprice !== '') {
  892. if (!uprice.test(parseFloat(this.create.temp.uprice))) {
  893. this.$message({ type: 'error', message: '单价请保留两位小数', duration: 2000 })
  894. return false
  895. }
  896. }
  897. if (this.create.temp.autozone !== '') {
  898. const autozone = /^([0-9]|(1[0-9]|2[0-9]|3[0-9]|4[0-9]|(50)))$/
  899. if (!autozone.test(parseFloat(this.create.temp.autozone))) {
  900. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于50的整数', duration: 2000 })
  901. return false
  902. }
  903. } else {
  904. this.create.temp.autozone = '0'
  905. }
  906. if (this.create.temp.trgaddress.length > 8) {
  907. this.$message({ type: 'error', message: '继电器位置请输入1-8位数字', duration: 2000 })
  908. return false
  909. }
  910. const allowratio = /^[0-9]\d*$/
  911. if (this.create.temp.allowratio !== '') {
  912. if (!allowratio.test(parseFloat(this.create.temp.allowratio))) {
  913. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  914. return false
  915. }
  916. }
  917. this.isokDisable = true
  918. setTimeout(() => {
  919. this.isokDisable = false
  920. }, 1000)
  921. this.requestParam.name = 'insertFeed'
  922. this.requestParam.parammaps = this.create.temp
  923. if (this.create.temp.allowratio == '') { this.create.temp.allowratio = '0' }
  924. if (this.create.temp.uprice == '') { this.create.temp.uprice = '0' }
  925. if (this.create.temp.unitweight == '') { this.create.temp.unitweight = '0' }
  926. if (this.create.temp.autozone == '') { this.create.temp.autozone = '0' }
  927. if (this.create.temp.trgaddress == '') { this.create.temp.trgaddress = '0' }
  928. PostDataByName(this.requestParam).then(response => {
  929. console.log('新增保存发送参数', this.requestParam)
  930. if (response.msg !== 'fail') {
  931. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  932. this.create.dialogFormVisible = false
  933. this.getList()
  934. } else {
  935. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  936. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  937. if (this.create.temp.uprice == '0') { this.create.temp.uprice = '' }
  938. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  939. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  940. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  941. }
  942. })
  943. }
  944. })
  945. },
  946. // 编辑
  947. handleUpdate(row) {
  948. console.log('点击了编辑', row)
  949. this.create.dialogStatus = 'update'
  950. this.create.dialogFormVisible = true
  951. row.fclassid = String(row.fclassid)
  952. row.printgroupid = String(row.printgroupid)
  953. row.autosecond = String(row.autosecond)
  954. row.confirmstart = String(row.confirmstart)
  955. row.enable = String(row.enable)
  956. row.jmp = String(row.jmp)
  957. this.create.temp = Object.assign({}, row)
  958. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  959. if (this.create.temp.uprice == '0.00') { this.create.temp.uprice = '' }
  960. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  961. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  962. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  963. if (this.create.temp.smtmrid == '-1') { this.create.temp.smtmrid = '' }
  964. },
  965. updateData() {
  966. console.log('点击了编辑保存')
  967. this.isokDisable = true
  968. setTimeout(() => {
  969. this.isokDisable = false
  970. }, 1000)
  971. this.$refs['temp'].validate(valid => {
  972. if (valid) {
  973. const unitweight = /^[1-9]\d*$/
  974. if (this.create.temp.unitweight !== '') {
  975. if (!unitweight.test(parseFloat(this.create.temp.unitweight))) {
  976. this.$message({ type: 'error', message: '包装单位重量请输入正整数', duration: 2000 })
  977. return false
  978. }
  979. }
  980. const uprice = /^\d+(\.\d{1,2})?$/
  981. if (this.create.temp.uprice !== '') {
  982. if (!uprice.test(parseFloat(this.create.temp.uprice))) {
  983. this.$message({ type: 'error', message: '单价请保留两位小数', duration: 2000 })
  984. return false
  985. }
  986. }
  987. if (this.create.temp.autozone !== '') {
  988. const autozone = /^([0-9]|(1[0-9]|2[0-9]|3[0-9]|4[0-9]|(50)))$/
  989. if (!autozone.test(parseFloat(this.create.temp.autozone))) {
  990. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于50的整数', duration: 2000 })
  991. return false
  992. }
  993. } else {
  994. this.create.temp.autozone = '0'
  995. }
  996. if (this.create.temp.trgaddress.length > 8) {
  997. this.$message({ type: 'error', message: '继电器位置请输入1-8位数字', duration: 2000 })
  998. return false
  999. }
  1000. const allowratio = /^[0-9]\d*$/
  1001. if (this.create.temp.allowratio !== '') {
  1002. if (!allowratio.test(parseFloat(this.create.temp.allowratio))) {
  1003. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  1004. return false
  1005. }
  1006. }
  1007. this.isokDisable = true
  1008. setTimeout(() => {
  1009. this.isokDisable = false
  1010. }, 1000)
  1011. this.requestParam.name = 'updateFeed'
  1012. this.requestParam.parammaps = this.create.temp
  1013. if (this.create.temp.allowratio == '') { this.create.temp.allowratio = '0' }
  1014. if (this.create.temp.uprice == '') { this.create.temp.uprice = '0' }
  1015. if (this.create.temp.unitweight == '') { this.create.temp.unitweight = '0' }
  1016. if (this.create.temp.autozone == '') { this.create.temp.autozone = '0' }
  1017. if (this.create.temp.trgaddress == '') { this.create.temp.trgaddress = '0' }
  1018. PostDataByName(this.requestParam).then(response => {
  1019. console.log('新增保存发送参数', this.requestParam)
  1020. if (response.msg !== 'fail') {
  1021. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1022. this.create.dialogFormVisible = false
  1023. this.getList()
  1024. } else {
  1025. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1026. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  1027. if (this.create.temp.uprice == '0') { this.create.temp.uprice = '' }
  1028. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  1029. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  1030. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  1031. }
  1032. })
  1033. }
  1034. })
  1035. },
  1036. // 饲料库
  1037. handleFeedBank() {
  1038. console.log('点击了饲料库')
  1039. this.feedBank.dialogStatus = 'feedBank'
  1040. this.feedBank.dialogFormVisible = true
  1041. this.getFeedBankList()
  1042. },
  1043. getFeedBankList() {
  1044. this.feedBank.listLoading = true
  1045. GetDataByName(this.feedBank.getdataListParm).then(response => {
  1046. console.log('table数据', response.data.list)
  1047. if (response.data.list !== null) {
  1048. this.feedBank.list = response.data.list
  1049. this.feedBank.pageNum = response.data.pageNum
  1050. this.feedBank.pageSize = response.data.pageSize
  1051. this.feedBank.total = response.data.total
  1052. } else {
  1053. this.feedBank.list = []
  1054. }
  1055. setTimeout(() => {
  1056. this.feedBank.listLoading = false
  1057. }, 100)
  1058. })
  1059. },
  1060. handleFeedBankSearch() {
  1061. console.log('点击了饲料库搜索')
  1062. this.getFeedBankList()
  1063. this.feedBank.getdataListParm.offset = 1
  1064. },
  1065. handleFeedBankRefresh() {
  1066. console.log('点击了饲料库重置')
  1067. this.feedBank.getdataListParm.parammaps.fname = ''
  1068. this.feedBank.getdataListParm.parammaps.statue = ''
  1069. this.getFeedBankList()
  1070. },
  1071. // 关联
  1072. handleRelation(row) {
  1073. console.log('点击了关联')
  1074. this.relation.dialogStatus = 'relation'
  1075. this.relation.dialogFormVisible = true
  1076. this.relation.temp = Object.assign({}, row)
  1077. this.relation.getdataListParm.parammaps.fid = this.relation.temp.id
  1078. this.getRelationList()
  1079. },
  1080. getRelationList() {
  1081. this.relation.listLoading = true
  1082. GetDataByName(this.relation.getdataListParm).then(response => {
  1083. console.log('table数据', response.data.list)
  1084. if (response.data.list !== null) {
  1085. this.relation.list = response.data.list
  1086. this.relation.pageNum = response.data.pageNum
  1087. this.relation.pageSize = response.data.pageSize
  1088. this.relation.total = response.data.total
  1089. } else {
  1090. this.relation.list = []
  1091. }
  1092. setTimeout(() => {
  1093. this.relation.listLoading = false
  1094. }, 100)
  1095. })
  1096. },
  1097. handleRelationSearch() {
  1098. console.log('点击了关联搜索')
  1099. this.relation.getdataListParm.offset = 1
  1100. this.getRelationList()
  1101. },
  1102. disassociateData(row) {
  1103. console.log('点击了取消关联')
  1104. MessageBox.confirm('是否确认取消关联?', {
  1105. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1106. }).then(() => {
  1107. this.isokDisable = true
  1108. setTimeout(() => {
  1109. this.isokDisable = false
  1110. }, 1000)
  1111. this.requestParam.name = 'updateFeedrelation'
  1112. this.requestParam.parammaps = {}
  1113. this.requestParam.parammaps.pastureid = this.relation.temp.pastureid
  1114. this.requestParam.parammaps.fid = this.relation.temp.id
  1115. this.requestParam.parammaps.id = row.id
  1116. PostDataByName(this.requestParam).then(response => {
  1117. console.log('取消关联保存发送参数', this.requestParam)
  1118. if (response.msg !== 'fail') {
  1119. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1120. this.getRelationList()
  1121. this.getList()
  1122. } else {
  1123. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1124. }
  1125. })
  1126. }).catch(() => {
  1127. this.$message({ type: 'info', message: '已取消' })
  1128. })
  1129. },
  1130. relationData(row) {
  1131. console.log('点击了关联保存')
  1132. MessageBox.confirm('是否确认关联?', {
  1133. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1134. }).then(() => {
  1135. this.isokDisable = true
  1136. setTimeout(() => {
  1137. this.isokDisable = false
  1138. }, 1000)
  1139. this.requestParam.name = 'insertFeednur'
  1140. this.requestParam.parammaps = {}
  1141. this.requestParam.parammaps.pastureid = this.relation.temp.pastureid
  1142. this.requestParam.parammaps.fid = this.relation.temp.id
  1143. this.requestParam.parammaps.fname = this.relation.temp.fname
  1144. this.requestParam.parammaps.feedcode = this.relation.temp.feedcode
  1145. this.requestParam.parammaps.price = row.price
  1146. this.requestParam.parammaps.remark = row.remark
  1147. this.requestParam.parammaps.dry = row.dry
  1148. this.requestParam.parammaps.starch = row.starch
  1149. this.requestParam.parammaps.cp = row.cp
  1150. this.requestParam.parammaps.ca = row.ca
  1151. this.requestParam.parammaps.p = row.p
  1152. this.requestParam.parammaps.n = row.n
  1153. this.requestParam.parammaps.fat = row.fat
  1154. this.requestParam.parammaps.adf = row.adf
  1155. this.requestParam.parammaps.ndf = row.ndf
  1156. this.requestParam.parammaps.ndip = row.ndip
  1157. this.requestParam.parammaps.ash = row.ash
  1158. this.requestParam.parammaps.fpercent = row.fpercent
  1159. this.requestParam.parammaps.iscu = row.iscu
  1160. this.requestParam.parammaps.feednurid = row.id
  1161. PostDataByName(this.requestParam).then(response => {
  1162. console.log('关联保存发送参数', this.requestParam)
  1163. if (response.msg !== 'fail') {
  1164. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1165. this.getRelationList()
  1166. this.getList()
  1167. } else {
  1168. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1169. }
  1170. })
  1171. }).catch(() => {
  1172. this.$message({ type: 'info', message: '已取消' })
  1173. })
  1174. },
  1175. // 营养价值
  1176. handleNutritive(row) {
  1177. console.log('点击了营养价值', row)
  1178. this.nutritive.dialogStatus = 'nutritive'
  1179. this.nutritive.dialogFormVisible = true
  1180. this.nutritive.temp = Object.assign({}, row)
  1181. },
  1182. nutritiveData() {
  1183. console.log('点击了营养价值保存')
  1184. this.isokDisable = true
  1185. setTimeout(() => {
  1186. this.isokDisable = false
  1187. }, 1000)
  1188. if (this.nutritive.temp.dry == undefined) { this.$set(this.nutritive.temp, 'dry', '') }
  1189. if (this.nutritive.temp.starch == undefined) { this.$set(this.nutritive.temp, 'starch', '') }
  1190. if (this.nutritive.temp.cp == undefined) { this.$set(this.nutritive.temp, 'cp', '') }
  1191. if (this.nutritive.temp.ca == undefined) { this.$set(this.nutritive.temp, 'ca', '') }
  1192. if (this.nutritive.temp.p == undefined) { this.$set(this.nutritive.temp, 'p', '') }
  1193. if (this.nutritive.temp.n == undefined) { this.$set(this.nutritive.temp, 'n', '') }
  1194. if (this.nutritive.temp.fat == undefined) { this.$set(this.nutritive.temp, 'fat', '') }
  1195. if (this.nutritive.temp.adf == undefined) { this.$set(this.nutritive.temp, 'adf', '') }
  1196. if (this.nutritive.temp.ndf == undefined) { this.$set(this.nutritive.temp, 'ndf', '') }
  1197. if (this.nutritive.temp.ndip == undefined) { this.$set(this.nutritive.temp, 'ndip', '') }
  1198. if (this.nutritive.temp.ash == undefined) { this.$set(this.nutritive.temp, 'ash', '') }
  1199. var positiveNumber = /^\d+(\.\d{1,2})?$/
  1200. if (this.nutritive.temp.dry !== '') {
  1201. if (!positiveNumber.test(parseFloat(this.nutritive.temp.dry))) {
  1202. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1203. return false
  1204. }
  1205. }
  1206. console.log(this.nutritive.temp.starch)
  1207. if (this.nutritive.temp.starch !== '') {
  1208. if (!positiveNumber.test(parseFloat(this.nutritive.temp.starch))) {
  1209. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1210. return false
  1211. }
  1212. }
  1213. if (this.nutritive.temp.cp !== '') {
  1214. if (!positiveNumber.test(parseFloat(this.nutritive.temp.cp))) {
  1215. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1216. return false
  1217. }
  1218. }
  1219. if (this.nutritive.temp.ca !== '') {
  1220. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ca))) {
  1221. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1222. return false
  1223. }
  1224. }
  1225. if (this.nutritive.temp.p !== '') {
  1226. if (!positiveNumber.test(parseFloat(this.nutritive.temp.p))) {
  1227. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1228. return false
  1229. }
  1230. }
  1231. if (this.nutritive.temp.n !== '') {
  1232. if (!positiveNumber.test(parseFloat(this.nutritive.temp.n))) {
  1233. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1234. return false
  1235. }
  1236. }
  1237. if (this.nutritive.temp.fat !== '') {
  1238. if (!positiveNumber.test(parseFloat(this.nutritive.temp.fat))) {
  1239. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1240. return false
  1241. }
  1242. }
  1243. if (this.nutritive.temp.adf !== '') {
  1244. if (!positiveNumber.test(parseFloat(this.nutritive.temp.adf))) {
  1245. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1246. return false
  1247. }
  1248. }
  1249. if (this.nutritive.temp.ndf !== '') {
  1250. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ndf))) {
  1251. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1252. return false
  1253. }
  1254. }
  1255. if (this.nutritive.temp.ndip !== '') {
  1256. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ndip))) {
  1257. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1258. return false
  1259. }
  1260. }
  1261. if (this.nutritive.temp.ash !== '') {
  1262. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ash))) {
  1263. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1264. return false
  1265. }
  1266. }
  1267. this.requestParam.name = 'insertFeednur'
  1268. this.requestParam.parammaps = {}
  1269. this.requestParam.parammaps.pastureid = this.nutritive.temp.pastureid
  1270. this.requestParam.parammaps.fid = this.nutritive.temp.id
  1271. this.requestParam.parammaps.fname = this.nutritive.temp.fname
  1272. this.requestParam.parammaps.feedcode = this.nutritive.temp.feedcode
  1273. this.requestParam.parammaps.price = this.nutritive.temp.uprice
  1274. this.requestParam.parammaps.remark = this.nutritive.temp.remark
  1275. this.requestParam.parammaps.dry = this.nutritive.temp.dry
  1276. this.requestParam.parammaps.starch = this.nutritive.temp.starch
  1277. this.requestParam.parammaps.cp = this.nutritive.temp.cp
  1278. this.requestParam.parammaps.ca = this.nutritive.temp.ca
  1279. this.requestParam.parammaps.p = this.nutritive.temp.p
  1280. this.requestParam.parammaps.n = this.nutritive.temp.n
  1281. this.requestParam.parammaps.fat = this.nutritive.temp.fat
  1282. this.requestParam.parammaps.adf = this.nutritive.temp.adf
  1283. this.requestParam.parammaps.ndf = this.nutritive.temp.ndf
  1284. this.requestParam.parammaps.ndip = this.nutritive.temp.ndip
  1285. this.requestParam.parammaps.ash = this.nutritive.temp.ash
  1286. this.requestParam.parammaps.fpercent = this.nutritive.temp.fpercent
  1287. this.requestParam.parammaps.iscu = this.nutritive.temp.iscu
  1288. this.requestParam.parammaps.feednurid = '-1'
  1289. PostDataByName(this.requestParam).then(response => {
  1290. console.log('关联保存发送参数', this.requestParam)
  1291. if (response.msg !== 'fail') {
  1292. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1293. this.getList()
  1294. this.nutritive.dialogFormVisible = false
  1295. } else {
  1296. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1297. }
  1298. })
  1299. },
  1300. // 行内删除
  1301. handleRowDelete(row) {
  1302. console.log('点击了行内删除')
  1303. MessageBox.confirm('是否确认删除此信息?', {
  1304. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1305. }).then(() => {
  1306. this.selectList = []
  1307. this.requestParam = {}
  1308. this.requestParam.common = { 'returnmap': '0' }
  1309. this.requestParam.data = []
  1310. this.requestParam.data[0] = { 'name': 'checkDeleteFeed', 'type': 'v', 'parammaps': {
  1311. 'pastureid': row.pastureid,
  1312. 'id': row.id
  1313. }}
  1314. this.requestParam.data[1] = { 'name': 'deleteFeed', 'type': 'e', 'parammaps': {
  1315. 'pastureid': row.pastureid,
  1316. 'id': row.id
  1317. }}
  1318. ExecDataByConfig(this.requestParam).then(response => {
  1319. console.log('删除保存发送参数', this.requestParam)
  1320. if (response.msg === 'fail') {
  1321. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1322. } else {
  1323. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1324. this.getList()
  1325. }
  1326. })
  1327. }).catch(() => {
  1328. this.$message({ type: 'info', message: '已取消删除' })
  1329. })
  1330. },
  1331. handleSelectionChange(val) {
  1332. console.log('勾选数据', val)
  1333. this.selectList = val
  1334. },
  1335. // 多项删除
  1336. handleDelete() {
  1337. console.log('点击了删除')
  1338. if (this.selectList.length == 0) {
  1339. this.$message({ type: 'error', message: '请选择饲料表信息', duration: 2000 })
  1340. } else {
  1341. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  1342. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1343. }).then(() => {
  1344. this.requestParam = {}
  1345. this.requestParam.common = { 'returnmap': '0' }
  1346. this.requestParam.data = []
  1347. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1348. this.requestParam.data[0].children = []
  1349. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteFeed', 'type': 'v', 'parammaps': {
  1350. id: '@insertSpotList.id',
  1351. pastureid: '@insertSpotList.pastureid'
  1352. }}
  1353. this.requestParam.data[0].children[1] = { 'name': 'deleteFeed', 'type': 'e', 'parammaps': {
  1354. id: '@insertSpotList.id',
  1355. pastureid: '@insertSpotList.pastureid'
  1356. }}
  1357. ExecDataByConfig(this.requestParam).then(response => {
  1358. console.log('删除保存发送参数', this.requestParam)
  1359. if (response.msg === 'fail') {
  1360. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1361. } else {
  1362. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1363. this.getList()
  1364. }
  1365. })
  1366. })
  1367. }
  1368. }
  1369. }
  1370. }
  1371. </script>
  1372. <style lang="scss" scoped>
  1373. .search{margin-top:10px;}
  1374. .table{margin-top:10px;}
  1375. $width:350px;
  1376. $left:325px;
  1377. .selectInput{
  1378. position: relative;
  1379. display: inline-block;
  1380. .Input{width: $width;position: relative;}
  1381. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  1382. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  1383. .selectUl{
  1384. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  1385. li{
  1386. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  1387. a{float:left;width: 80px;}
  1388. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  1389. }
  1390. }
  1391. }
  1392. </style>