a12c23ef502430f2f5e9368af9ac1bba158a80cb.svn-base 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247
  1. <template>
  2. <div class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <p class="recipeTemplate" />
  6. <div class="operation">
  7. <el-button class="success" @click="handleCreate">新增</el-button>
  8. <el-button class="danger" @click="handleDelete">删除</el-button>
  9. <el-button class="warning" @click="handleCopy">复制</el-button>
  10. <el-button class="success" @click="handleRecipeRecord">配方记录</el-button>
  11. <el-button class="success" @click="handleHistory">生成历史</el-button>
  12. <el-button class="import" style="float: right;margin-right: 80px;" @click="handleImport">导入</el-button>
  13. <el-button class="export" style="float: right;margin-right: 10px;" @click="handleExport">导出</el-button>
  14. </div>
  15. <div class="search">
  16. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  17. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  18. </el-select>
  19. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  20. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  21. </el-select>
  22. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  23. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  24. </el-select>
  25. <div ref="selectInput" class="filter-item selectInput">
  26. <el-input type="text" placeholder="请点击选择搜索条件" class="Input" />
  27. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  28. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  29. <ul v-if="arrowUp" class="selectUl">
  30. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  31. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  32. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  33. <li>
  34. <div style="float: right;">
  35. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  36. <el-button class="miniSuccess" @click="handleSearch">搜索</el-button>
  37. </div>
  38. </li>
  39. </ul>
  40. </div>
  41. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  42. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  43. </div>
  44. <div class="table">
  45. <el-table
  46. :key="table.tableKey"
  47. v-loading="table.listLoading"
  48. element-loading-text="给我一点时间"
  49. :data="table.list"
  50. border
  51. fit
  52. highlight-current-row
  53. style="width: 98%;"
  54. :row-style="rowStyle"
  55. :cell-style="cellStyle"
  56. class="elTable table-fixed"
  57. @row-click="tableRowClick"
  58. @selection-change="handleSelectionChange"
  59. >
  60. <el-table-column type="selection" align="center" width="50" />
  61. <el-table-column label="序号" align="center" type="index" width="50px">
  62. <template slot-scope="scope">
  63. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="配方名称" min-width="130px" align="center">
  67. <template slot-scope="scope">
  68. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  69. <el-input v-if="scope.row.Edit" v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="配方颜色" min-width="130px" align="center">
  73. <template slot-scope="scope">
  74. <el-color-picker v-model="scope.row.tcolor" size="mini" :disabled="scope.row.NoEdit" style="margin:10px 0;" />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="牲畜类别" min-width="150px" align="center">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  80. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  81. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  82. </el-select>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="配方类型" min-width="150px" align="center">
  86. <template slot-scope="scope">
  87. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  88. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  89. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  90. </el-select>
  91. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  92. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  93. </el-select>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="来源" min-width="110px" align="center">
  97. <template slot-scope="scope">
  98. <span>{{ scope.row.source }}</span>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="备注" min-width="110px" align="center">
  102. <template slot-scope="scope">
  103. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  104. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="是否启用" min-width="110px" align="center">
  108. <template slot-scope="scope">
  109. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  113. <template slot-scope="{row}">
  114. <!-- 新增 -->
  115. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData(row)">保存</el-button>
  116. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  117. <!-- 编辑 -->
  118. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  119. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  120. <!-- 编辑保存 -->
  121. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  122. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. </div>
  127. </div>
  128. <!-- 配方详情表 -->
  129. <div v-if="isDetail" ref="detail" class="detail" style="margin-top: 30px;">
  130. <p class="recipeDetail" />
  131. <div class="operation">
  132. <el-button class="success" @click="handleCreate2">新增</el-button>
  133. <el-button class="danger" @click="handleDelete2">删除</el-button>
  134. <el-button class="success" @click="handleSyntheticPremix">合成预混料</el-button>
  135. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  136. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  137. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  138. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  139. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  140. <li>
  141. <a style="width: 130px;">饲料名称</a>
  142. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  143. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  144. </el-select>
  145. </li>
  146. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  147. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  148. <li>
  149. <a style="width: 130px;">搅拌延时</a>
  150. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;" clearable>
  151. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  152. </el-select>
  153. </li>
  154. <li>
  155. <a style="width: 130px;">是否锁定牛头数比例</a>
  156. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;" clearable>
  157. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  158. </el-select>
  159. </li>
  160. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  161. <li>
  162. <div style="float: right;">
  163. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  164. <el-button class="miniSuccess" @click="handleSearch2">搜索</el-button>
  165. </div>
  166. </li>
  167. </ul>
  168. </div>
  169. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  170. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  171. </div>
  172. <div class="table2" style="min-height: 400px;">
  173. <el-table
  174. id="table2"
  175. ref="table2"
  176. :key="table2.tableKey"
  177. v-loading="table2.listLoading"
  178. element-loading-text="给我一点时间"
  179. :data="table2.list"
  180. border
  181. fit
  182. highlight-current-row
  183. style="width: 98%;"
  184. :row-style="rowStyle"
  185. :cell-style="cellStyle"
  186. class="elTable table-fixed"
  187. row-key="id"
  188. show-summary
  189. @selection-change="handleSelectionChange2"
  190. >
  191. <el-table-column type="selection" width="60" />
  192. <el-table-column label="序号" align="center" type="index" width="50px" />
  193. <el-table-column label="饲料组" min-width="110px" align="center">
  194. <template slot-scope="scope">
  195. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  196. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  197. </template>
  198. </el-table-column>
  199. <el-table-column label="饲料名称" min-width="130px" align="center">
  200. <template slot-scope="scope">
  201. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  202. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  203. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  204. </el-select>
  205. </template>
  206. </el-table-column>
  207. <el-table-column label="重量(KG)" prop="fweight" min-width="100px" align="center">
  208. <template slot-scope="scope">
  209. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  210. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  211. </template>
  212. </el-table-column>
  213. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  214. <template slot-scope="scope">
  215. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  216. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  217. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  218. </el-select>
  219. </template>
  220. </el-table-column>
  221. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="110px" align="center">
  222. <template slot-scope="scope">
  223. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  224. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  225. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  226. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  227. </el-select>
  228. </template>
  229. </el-table-column>
  230. <el-table-column label="顺序" min-width="100px" align="center">
  231. <template slot-scope="scope">
  232. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  233. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  234. </template>
  235. </el-table-column>
  236. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  237. <template slot-scope="{row}">
  238. <!-- 新增 -->
  239. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData2(row)">保存</el-button>
  240. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
  241. <!-- 编辑 -->
  242. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate2(row)">编辑</el-button>
  243. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete2(row)">删除</el-button>
  244. <!-- 编辑保存 -->
  245. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData2(row)">保存</el-button>
  246. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
  247. <!-- 拆分预混料 -->
  248. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false" class="miniSuccess" @click="handleSplitPremix(row)">拆分预混料</el-button>
  249. </template>
  250. </el-table-column>
  251. </el-table>
  252. </div>
  253. </div>
  254. <!-- 配方记录 -->
  255. <el-dialog :title="textMap[template.dialogStatus]" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  256. <div style="height: 400px;overflow: auto;margin-bottom: 30px;">
  257. <div ref="templateDialog" class="templateDialog">
  258. <p class="recipeTemplate" />
  259. <div class="operation">
  260. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  261. <el-button class="successBorder" @click="handleApplication">应用</el-button>
  262. </div>
  263. <div class="search">
  264. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  265. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  266. </el-select>
  267. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  268. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  269. </el-select>
  270. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  271. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  272. </el-select>
  273. <div ref="selectInput" class="filter-item selectInput">
  274. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  275. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  276. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  277. <ul v-if="arrowUp" class="selectUl">
  278. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  279. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  280. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  281. <li>
  282. <div style="float: right;">
  283. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  284. <el-button class="miniSuccess" @click="handleDialogSearch">搜索</el-button>
  285. </div>
  286. </li>
  287. </ul>
  288. </div>
  289. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  290. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  291. </div>
  292. <div class="table">
  293. <el-table
  294. :key="template.table.tableKey"
  295. v-loading="template.table.listLoading"
  296. element-loading-text="给我一点时间"
  297. :data="template.table.list"
  298. border
  299. fit
  300. highlight-current-row
  301. style="width: 98%;"
  302. :row-style="rowStyle"
  303. :cell-style="cellStyle"
  304. class="elTable table-fixed"
  305. @row-click="tableRowClickDialog"
  306. >
  307. <el-table-column label="序号" align="center" type="index" width="50px">
  308. <template slot-scope="scope">
  309. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  310. </template>
  311. </el-table-column>
  312. <el-table-column label="配方名称" min-width="130px" align="center">
  313. <template slot-scope="scope">
  314. <span>{{ scope.row.tname }}</span>
  315. </template>
  316. </el-table-column>
  317. <el-table-column label="配方颜色" min-width="130px" align="center">
  318. <template slot-scope="scope">
  319. <el-color-picker v-model="scope.row.tcolor" size="mini" disabled style="margin:10px 0;" />
  320. </template>
  321. </el-table-column>
  322. <el-table-column label="牲畜类别" min-width="150px" align="center">
  323. <template slot-scope="scope">
  324. <span>{{ scope.row.ccname }}</span>
  325. </template>
  326. </el-table-column>
  327. <el-table-column label="配方类型" min-width="150px" align="center">
  328. <template slot-scope="scope">
  329. <span>{{ scope.row.fttype }}</span>
  330. </template>
  331. </el-table-column>
  332. <el-table-column label="来源" min-width="110px" align="center">
  333. <template slot-scope="scope">
  334. <span>{{ scope.row.source }}</span>
  335. </template>
  336. </el-table-column>
  337. <el-table-column label="备注" min-width="110px" align="center">
  338. <template slot-scope="scope">
  339. <span>{{ scope.row.remark }}</span>
  340. </template>
  341. </el-table-column>
  342. <el-table-column label="是否启用" min-width="110px" align="center">
  343. <template slot-scope="scope">
  344. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  345. </template>
  346. </el-table-column>
  347. </el-table>
  348. </div>
  349. </div>
  350. <div v-if="isDetailDialog" class="detailDialog" style="margin-top: 30px;">
  351. <p class="recipeDetail" />
  352. <div class="operation">
  353. <div ref="selectInput2" class="filter-item selectInput">
  354. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  355. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  356. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  357. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  358. <li>
  359. <a style="width: 130px;">饲料名称</a>
  360. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  361. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  362. </el-select>
  363. </li>
  364. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  365. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  366. <li>
  367. <a style="width: 130px;">搅拌延时</a>
  368. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  369. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  370. </el-select>
  371. </li>
  372. <li>
  373. <a style="width: 130px;">是否锁定牛头数比例</a>
  374. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  375. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  376. </el-select>
  377. </li>
  378. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  379. <li>
  380. <div style="float: right;">
  381. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  382. <el-button class="miniSuccess" @click="handleDialogSearch2">搜索</el-button>
  383. </div>
  384. </li>
  385. </ul>
  386. </div>
  387. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  388. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  389. </div>
  390. <div class="table2">
  391. <el-table
  392. :key="template.table2.tableKey"
  393. v-loading="template.table2.listLoading"
  394. element-loading-text="给我一点时间"
  395. :data="template.table2.list"
  396. border
  397. fit
  398. highlight-current-row
  399. style="width: 98%;"
  400. :row-style="rowStyle"
  401. :cell-style="cellStyle"
  402. class="elTable table-fixed"
  403. row-key="id"
  404. >
  405. <el-table-column label="饲料组" min-width="130px" align="center">
  406. <template slot-scope="scope">
  407. <span>{{ scope.row.feedgroup }}</span>
  408. </template>
  409. </el-table-column>
  410. <el-table-column label="饲料名称" min-width="130px" align="center">
  411. <template slot-scope="scope">
  412. <span>{{ scope.row.fname }}</span>
  413. </template>
  414. </el-table-column>
  415. <el-table-column label="重量(KG)" min-width="130px" align="center">
  416. <template slot-scope="scope">
  417. <span>{{ scope.row.fweight }}</span>
  418. </template>
  419. </el-table-column>
  420. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  421. <template slot-scope="scope">
  422. <span>{{ scope.row.autosecondname }}</span>
  423. </template>
  424. </el-table-column>
  425. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  426. <template slot-scope="scope">
  427. <span v-if="scope.row.islockcount == '0'">否</span>
  428. <span v-if="scope.row.islockcount == '1'">是</span>
  429. </template>
  430. </el-table-column>
  431. <el-table-column label="顺序" min-width="130px" align="center">
  432. <template slot-scope="scope">
  433. <span>{{ scope.row.sort }}</span>
  434. </template>
  435. </el-table-column>
  436. </el-table>
  437. </div>
  438. </div>
  439. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  440. <el-button @click="template.dialogFormVisible = false; ">关闭</el-button>
  441. </div>
  442. </div>
  443. </el-dialog>
  444. <!-- 合成预混料 -->
  445. <el-dialog :title="textMap[detail.dialogStatus]" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  446. <div class="detailDialog">
  447. <h2>饲料</h2>
  448. <div class="table1">
  449. <el-table
  450. :key="detail.tableKey"
  451. v-loading="detail.listLoading"
  452. element-loading-text="给我一点时间"
  453. :data="detail.list"
  454. fit
  455. highlight-current-row
  456. style="width: 100%;"
  457. :row-style="rowStyle"
  458. :cell-style="cellStyle"
  459. class="elTable table-fixed"
  460. show-summary
  461. >
  462. <el-table-column label="序号" align="center" type="index" width="50px" />
  463. <el-table-column label="饲料名称" min-width="130px" align="center">
  464. <template slot-scope="scope">
  465. <span>{{ scope.row.fname }}</span>
  466. </template>
  467. </el-table-column>
  468. <el-table-column prop="fweight" sortable label="重量(KG)" />
  469. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  470. <template slot-scope="scope">
  471. <span>{{ scope.row.autosecond }}</span>
  472. </template>
  473. </el-table-column>
  474. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  475. <template slot-scope="scope">
  476. <span v-if="scope.row.islockcount == '0'">否</span>
  477. <span v-if="scope.row.islockcount == '1'">是</span>
  478. </template>
  479. </el-table-column>
  480. <el-table-column label="顺序" min-width="110px" align="center">
  481. <template slot-scope="scope">
  482. <span>{{ scope.row.sort }}</span>
  483. </template>
  484. </el-table-column>
  485. </el-table>
  486. </div>
  487. <h2>合成预混料</h2>
  488. <div class="table2" style="margin-bottom: 50px;">
  489. <el-table
  490. :key="detail.tableKey2"
  491. v-loading="detail.listLoading2"
  492. element-loading-text="给我一点时间"
  493. :data="detail.list2"
  494. border
  495. fit
  496. highlight-current-row
  497. style="width: 100%;"
  498. :row-style="rowStyle"
  499. :cell-style="cellStyle"
  500. class="elTable table-fixed"
  501. >
  502. <el-table-column label="配方名称" min-width="130px" align="center">
  503. <template slot-scope="scope">
  504. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  505. </template>
  506. </el-table-column>
  507. <el-table-column label="配方颜色" min-width="130px" align="center">
  508. <template slot-scope="scope">
  509. <el-color-picker v-model="scope.row.tcolor" size="mini" style="margin:10px 0;" :disabled="detail.disabled" />
  510. </template>
  511. </el-table-column>
  512. <el-table-column label="牲畜类别" min-width="130px" align="center">
  513. <template slot-scope="scope">
  514. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  515. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  516. </el-select>
  517. </template>
  518. </el-table-column>
  519. <el-table-column label="配方类型" min-width="110px" align="center">
  520. <template slot-scope="scope">
  521. <span>{{ scope.row.fttype }}</span>
  522. </template>
  523. </el-table-column>
  524. <el-table-column label="来源" min-width="110px" align="center">
  525. <template slot-scope="scope">
  526. <span>{{ scope.row.source }}</span>
  527. </template>
  528. </el-table-column>
  529. <el-table-column label="备注" min-width="130px" align="center">
  530. <template slot-scope="scope">
  531. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  532. </template>
  533. </el-table-column>
  534. <el-table-column label="是否启用" min-width="130px" align="center">
  535. <template slot-scope="scope">
  536. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  537. </template>
  538. </el-table-column>
  539. </el-table>
  540. </div>
  541. <div slot="footer" class="dialog-footer" style="bottom: -50px;">
  542. <el-button class="cancel" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  543. <el-button class="success" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  544. </div>
  545. </div>
  546. </el-dialog>
  547. </div>
  548. </template>
  549. <script>
  550. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  551. import Sortable from 'sortablejs'
  552. import { MessageBox } from 'element-ui'
  553. import Cookies from 'js-cookie'
  554. export default {
  555. name: 'RecipeTemplate',
  556. data() {
  557. return {
  558. requestParams: [
  559. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  560. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  561. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  562. ],
  563. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  564. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  565. livestockTypeList: [], // 牲畜类别
  566. formulaTypeList: [], // 配方类型
  567. feedNameList: [], // 饲料名称
  568. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  569. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  570. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  571. arrowDown: true,
  572. arrowUp: false,
  573. table: {
  574. getdataListParm: {
  575. name: 'getFTList',
  576. page: 1,
  577. offset: 1,
  578. pagecount: 30,
  579. returntype: 'Map',
  580. parammaps: {
  581. pastureid: Cookies.get('pastureid'),
  582. tname: '',
  583. ccid: '',
  584. ccname: '',
  585. fttypeid: '',
  586. fttype: '',
  587. remark: '',
  588. enable: ''
  589. }
  590. },
  591. tableKey: 0,
  592. list: [],
  593. total: 0,
  594. listLoading: true,
  595. temp: {}
  596. },
  597. lockCount: {
  598. getdataListParm: {
  599. name: 'getSysoptEnable',
  600. page: 1,
  601. offset: 1,
  602. pagecount: 30,
  603. returntype: 'Map',
  604. parammaps: {
  605. pastureid: Cookies.get('pastureid'),
  606. inforname: 'isLockCount'
  607. }
  608. },
  609. isLockCount: false // 是否显示是否锁定牛头数比例
  610. },
  611. isDetail: false,
  612. arrowDown2: true,
  613. arrowUp2: false,
  614. table2: {
  615. getdataListParm: {
  616. name: 'getFTdetailList',
  617. page: 1,
  618. offset: 1,
  619. pagecount: 10,
  620. returntype: 'Map',
  621. parammaps: {
  622. pastureid: Cookies.get('pastureid'),
  623. fname: '',
  624. feedgroup: '',
  625. fweight: '',
  626. autosecondname: '',
  627. islockcount: '',
  628. sort: ''
  629. }
  630. },
  631. tableKey: 0,
  632. list: [],
  633. total: 0,
  634. listLoading: true,
  635. temp: {}
  636. },
  637. isDetailDialog: false,
  638. template: {
  639. dialogFormVisible: false,
  640. dialogStatus: '',
  641. table: {
  642. getdataListParm: {
  643. name: 'getFTListDate',
  644. page: 1,
  645. offset: 1,
  646. pagecount: 10,
  647. returntype: 'Map',
  648. parammaps: {
  649. pastureid: Cookies.get('pastureid'),
  650. tname: '',
  651. ccid: '',
  652. ccname: '',
  653. fttype: '',
  654. remark: '',
  655. enable: '',
  656. date: '',
  657. source: ''
  658. }
  659. },
  660. tableKey: 0,
  661. total: 0,
  662. listLoading: true,
  663. list: []
  664. },
  665. table2: {
  666. getdataListParm: {
  667. name: 'getFTdetailListDate',
  668. page: 1,
  669. offset: 1,
  670. pagecount: 10,
  671. returntype: 'Map',
  672. parammaps: {
  673. pastureid: Cookies.get('pastureid'),
  674. fname: '',
  675. fweight: '',
  676. islockcount: '',
  677. sort: '',
  678. feedgroup: '',
  679. autosecondname: ''
  680. }
  681. },
  682. tableKey: 0,
  683. total: 0,
  684. listLoading: true,
  685. list: []
  686. },
  687. // 历史日期
  688. getdataDateParm: {
  689. name: 'getFTMaxDate',
  690. page: 1,
  691. offset: 1,
  692. pagecount: 10,
  693. returntype: 'Map',
  694. parammaps: {
  695. pastureid: Cookies.get('pastureid')
  696. }
  697. }
  698. },
  699. detail: {
  700. dialogFormVisible: false,
  701. dialogStatus: '',
  702. tableKey: 0,
  703. total: 0,
  704. listLoading: true,
  705. list: [],
  706. tableKey2: 0,
  707. total2: 0,
  708. listLoading2: false,
  709. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  710. getdataListParm: {
  711. name: 'getFTDetailCompare',
  712. page: 1,
  713. offset: 1,
  714. pagecount: 10,
  715. returntype: 'Map',
  716. parammaps: {}
  717. },
  718. list3: [],
  719. disabled: false,
  720. getdataListParm2: {
  721. name: 'getFTCompare',
  722. page: 1,
  723. offset: 1,
  724. pagecount: 10,
  725. returntype: 'Map',
  726. parammaps: {}
  727. }
  728. },
  729. selectList: [],
  730. selectList2: [],
  731. textMap: {
  732. RecipeRecord: '配方记录',
  733. SyntheticPremix: '合成预混料'
  734. },
  735. requestParam: {},
  736. isokDisable: false,
  737. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  738. cellStyle: { padding: 0 + 'px' },
  739. dropState: false
  740. }
  741. },
  742. mounted() {
  743. document.addEventListener('click', (e) => {
  744. if (this.$refs.selectInput !== undefined) {
  745. if (!this.$refs.selectInput.contains(e.target)) {
  746. this.arrowDown = true
  747. this.arrowUp = false
  748. } else {
  749. this.arrowDown = false
  750. this.arrowUp = true
  751. }
  752. }
  753. if (this.$refs.selectInput2 !== undefined) {
  754. if (!this.$refs.selectInput2.contains(e.target)) {
  755. this.arrowDown2 = true
  756. this.arrowUp2 = false
  757. } else {
  758. this.arrowDown2 = false
  759. this.arrowUp2 = true
  760. }
  761. }
  762. })
  763. },
  764. created() {
  765. this.getList()
  766. this.getDownList()
  767. this.getIsLockCount()
  768. },
  769. methods: {
  770. handleHistory() {
  771. MessageBox.confirm('是否确认生成历史?', {
  772. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  773. }).then(() => {
  774. this.requestParam.name = 'creatFTdate'
  775. this.requestParam.parammaps = {}
  776. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  777. PostDataByName(this.requestParam).then(response => {
  778. console.log('生成历史保存发送参数', this.requestParam)
  779. if (response.msg !== 'fail') {
  780. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  781. } else {
  782. failproccess(response, this.$notify)
  783. }
  784. })
  785. })
  786. },
  787. getDownList() {
  788. GetDataByNames(this.requestParams).then(response => {
  789. this.livestockTypeList = response.data.getDictByName.list
  790. this.formulaTypeList = response.data.getDictByName2.list
  791. this.feedNameList = response.data.getFeedAndPre.list
  792. })
  793. },
  794. // -------------------模板-----------------------------
  795. getList() {
  796. this.table.listLoading = true
  797. GetDataByName(this.table.getdataListParm).then(response => {
  798. console.log('table数据', response.data.list)
  799. if (response.data.list !== null) {
  800. for (let i = 0; i < response.data.list.length; i++) {
  801. this.$set(response.data.list[i], 'Edit', false) // 编辑
  802. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  803. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  804. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  805. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  806. }
  807. this.table.list = response.data.list
  808. this.table.pageNum = response.data.pageNum
  809. this.table.pageSize = response.data.pageSize
  810. this.table.total = response.data.total
  811. } else {
  812. this.table.list = []
  813. }
  814. setTimeout(() => {
  815. this.table.listLoading = false
  816. }, 100)
  817. })
  818. },
  819. handleSearch() {
  820. console.log('点击了查询')
  821. this.table.getdataListParm.offset = 1
  822. this.getList()
  823. this.arrowDown = true
  824. this.arrowUp = false
  825. },
  826. handleRefresh() {
  827. console.log('点击了重置')
  828. this.table.getdataListParm.offset = 1
  829. this.table.getdataListParm.parammaps.ccid = ''
  830. this.table.getdataListParm.parammaps.ccname = ''
  831. this.table.getdataListParm.parammaps.fttype = ''
  832. this.table.getdataListParm.parammaps.tname = ''
  833. this.table.getdataListParm.parammaps.remark = ''
  834. this.table.getdataListParm.parammaps.enable = ''
  835. this.table.getdataListParm.parammaps.source = ''
  836. this.getList()
  837. },
  838. // 模板新增
  839. handleCreate() {
  840. console.log('点击了新增')
  841. // 编辑true/不可编辑false
  842. // 新增操true,编辑false,编辑保存false
  843. for (let i = 0; i < this.table.list.length; i++) {
  844. if (this.table.list[i].Edit === true) {
  845. console.log(123)
  846. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  847. return false
  848. }
  849. }
  850. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  851. console.log(this.table.list)
  852. },
  853. // 畜生类别
  854. changeLivestockType(item) {
  855. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  856. },
  857. // 配方类型
  858. changeFormulaType(item) {
  859. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  860. },
  861. createData(row) {
  862. console.log('点击了新增保存', row)
  863. this.table.temp.tname = row.tname
  864. this.table.temp.tcolor = row.tcolor
  865. this.table.temp.ccid = row.ccid
  866. this.table.temp.ccname = this.table.temp.ccname
  867. this.table.temp.fttype = this.table.temp.fttype
  868. this.table.temp.fttypeid = row.fttypeid
  869. this.table.temp.source = row.source
  870. this.table.temp.remark = row.remark
  871. this.table.temp.enable = row.enable
  872. this.table.temp.pastureid = Cookies.get('pastureid')
  873. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  874. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  875. return false
  876. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  877. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  878. return false
  879. } else if (this.table.temp.tname == '') {
  880. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  881. return false
  882. } else if (this.table.temp.ccid == '') {
  883. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  884. return false
  885. } else if (this.table.temp.fttypeid == '') {
  886. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  887. return false
  888. }
  889. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  890. if (pattern.test(this.table.temp.tname)) {
  891. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  892. return false
  893. }
  894. console.log(this.table.temp)
  895. this.isokDisable = true
  896. setTimeout(() => {
  897. this.isokDisable = false
  898. }, 1000)
  899. this.requestParam.name = 'insertFT'
  900. this.requestParam.parammaps = this.table.temp
  901. PostDataByName(this.requestParam).then(response => {
  902. console.log('新增保存发送参数', this.requestParam)
  903. if (response.msg !== 'fail') {
  904. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  905. this.getList()
  906. } else {
  907. failproccess(response, this.$notify)
  908. }
  909. })
  910. },
  911. createCancel(row) {
  912. console.log('点击了新增取消')
  913. for (let i = 0; i < this.table.list.length; i++) {
  914. if (row.myId === this.table.list[i].myId) {
  915. var listIndex = this.table.list.indexOf(this.table.list[i])
  916. }
  917. if (listIndex > -1) {
  918. this.table.list.splice(listIndex, 1)
  919. return
  920. }
  921. }
  922. },
  923. // 模板编辑
  924. handleUpdate(row) {
  925. for (let i = 0; i < this.table.list.length; i++) {
  926. if (this.table.list[i].Edit == true) {
  927. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  928. return false
  929. }
  930. }
  931. // 编辑true,不可编辑false
  932. row.Edit = true
  933. row.NoEdit = false
  934. // 新增false,编辑false,编辑保存true
  935. row.isCreate = false
  936. row.isUpdate = false
  937. row.isUpdateSave = true
  938. row.ccid = String(row.ccid)
  939. row.fttypeid = String(row.fttypeid)
  940. this.table.temp.ccname = row.ccname
  941. this.table.temp.fttype = row.fttype
  942. },
  943. updateData(row) {
  944. console.log('点击了编辑保存', row)
  945. this.table.temp.tname = row.tname
  946. this.table.temp.tcolor = row.tcolor
  947. this.table.temp.ccid = row.ccid
  948. this.table.temp.fttypeid = row.fttypeid
  949. this.table.temp.source = row.source
  950. this.table.temp.remark = row.remark
  951. this.table.temp.enable = row.enable
  952. this.table.temp.ccname = this.table.temp.ccname
  953. this.table.temp.fttype = this.table.temp.fttype
  954. this.table.temp.pastureid = row.pastureid
  955. this.table.temp.id = row.id
  956. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  957. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  958. return false
  959. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  960. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  961. return false
  962. } else if (this.table.temp.tname == '') {
  963. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  964. return false
  965. } else if (this.table.temp.ccid == '') {
  966. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  967. return false
  968. } else if (this.table.temp.fttypeid == '') {
  969. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  970. return false
  971. }
  972. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  973. if (pattern.test(this.table.temp.tname)) {
  974. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  975. return false
  976. }
  977. console.log(this.table.temp)
  978. this.isokDisable = true
  979. setTimeout(() => {
  980. this.isokDisable = false
  981. }, 1000)
  982. this.requestParam.name = 'updateFT'
  983. this.requestParam.parammaps = this.table.temp
  984. PostDataByName(this.requestParam).then(response => {
  985. console.log('新增保存发送参数', this.requestParam)
  986. if (response.msg !== 'fail') {
  987. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  988. this.getList()
  989. } else {
  990. failproccess(response, this.$notify)
  991. }
  992. })
  993. },
  994. updateCancel(row) {
  995. console.log('点击了编辑取消')
  996. // 编辑false,不可编辑true
  997. row.Edit = false
  998. row.NoEdit = true
  999. // 新增false,编辑true,编辑保存false
  1000. row.isCreate = false
  1001. row.isUpdate = true
  1002. row.isUpdateSave = false
  1003. this.getList()
  1004. },
  1005. // 删除
  1006. handleRowDelete(row) {
  1007. console.log('点击了行内删除')
  1008. MessageBox.confirm('是否确认删除此信息?', {
  1009. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1010. }).then(() => {
  1011. this.requestParam.common = { 'returnmap': '0' }
  1012. this.requestParam.data = []
  1013. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1014. pastureid: row.pastureid,
  1015. id: row.id
  1016. }}
  1017. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1018. pastureid: row.pastureid,
  1019. id: row.id
  1020. }}
  1021. ExecDataByConfig(this.requestParam).then(response => {
  1022. console.log('新增保存发送参数', this.requestParam)
  1023. if (response.msg === 'fail') {
  1024. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1025. } else {
  1026. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1027. this.getList()
  1028. }
  1029. })
  1030. }).catch(() => {
  1031. this.$message({ type: 'info', message: '已取消删除' })
  1032. })
  1033. },
  1034. handleSelectionChange(val) {
  1035. console.log('勾选数据', val)
  1036. this.selectList = val
  1037. },
  1038. handleDelete() {
  1039. console.log('点击了删除')
  1040. if (this.selectList.length == 0) {
  1041. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1042. } else {
  1043. MessageBox.confirm('是否确认删除此信息?', {
  1044. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1045. }).then(() => {
  1046. console.log(this.selectList)
  1047. this.requestParam.common = { 'returnmap': '0' }
  1048. this.requestParam.data = []
  1049. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1050. this.requestParam.data[0].children = []
  1051. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1052. id: '@insertSpotList.id',
  1053. pastureid: '@insertSpotList.pastureid'
  1054. }}
  1055. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1056. id: '@insertSpotList.id',
  1057. pastureid: '@insertSpotList.pastureid'
  1058. }}
  1059. ExecDataByConfig(this.requestParam).then(response => {
  1060. console.log('删除保存发送参数', this.requestParam)
  1061. if (response.msg === 'fail') {
  1062. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1063. } else {
  1064. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1065. this.getList()
  1066. }
  1067. })
  1068. })
  1069. }
  1070. },
  1071. // 复制
  1072. handleCopy() {
  1073. if (this.selectList.length == 0) {
  1074. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1075. } else {
  1076. MessageBox.confirm('是否确认复制此信息?', {
  1077. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1078. }).then(() => {
  1079. console.log(this.selectList)
  1080. this.requestParam.common = { 'returnmap': '0' }
  1081. this.requestParam.data = []
  1082. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1083. this.requestParam.data[0].children = []
  1084. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1085. ftid: '@insertSpotList.id',
  1086. pastureid: '@insertSpotList.pastureid'
  1087. }}
  1088. ExecDataByConfig(this.requestParam).then(response => {
  1089. console.log('复制保存发送参数', this.requestParam)
  1090. if (response.msg === 'fail') {
  1091. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1092. } else {
  1093. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1094. this.getList()
  1095. }
  1096. })
  1097. })
  1098. }
  1099. },
  1100. // 配方记录
  1101. handleRecipeRecord() {
  1102. console.log('点击了配方记录')
  1103. this.template.dialogStatus = 'RecipeRecord'
  1104. this.template.dialogFormVisible = true
  1105. this.template.table.getdataListParm.parammaps.ccname = ''
  1106. this.template.table.getdataListParm.parammaps.fttype = ''
  1107. this.template.table.getdataListParm.parammaps.enable = ''
  1108. this.template.table.getdataListParm.parammaps.tname = ''
  1109. this.template.table.getdataListParm.parammaps.remark = ''
  1110. this.template.table.getdataListParm.parammaps.source = ''
  1111. this.template.table.getdataListParm.offset = 1
  1112. this.getDateList()
  1113. this.isDetailDialog = false
  1114. },
  1115. // 历史时间
  1116. getDateList() {
  1117. GetDataByName(this.template.getdataDateParm).then(response => {
  1118. console.log('table数据', response.data.list)
  1119. if (response.data.list !== null) {
  1120. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1121. this.getTemplateDialogList()
  1122. } else {
  1123. this.template.table.getdataListParm.parammaps.date = ''
  1124. }
  1125. })
  1126. },
  1127. // 配方记录-模板
  1128. getTemplateDialogList() {
  1129. this.template.table.listLoading = true
  1130. GetDataByName(this.template.table.getdataListParm).then(response => {
  1131. console.log('table数据', response.data.list)
  1132. if (response.data.list !== null) {
  1133. this.template.table.list = response.data.list
  1134. this.template.table.pageNum = response.data.pageNum
  1135. this.template.table.pageSize = response.data.pageSize
  1136. this.template.table.total = response.data.total
  1137. } else {
  1138. this.template.table.list = []
  1139. }
  1140. setTimeout(() => {
  1141. this.template.table.listLoading = false
  1142. }, 100)
  1143. })
  1144. },
  1145. handleDialogSearch() {
  1146. this.template.table.getdataListParm.offset = 1
  1147. this.getTemplateDialogList()
  1148. this.arrowDown = true
  1149. this.arrowUp = false
  1150. },
  1151. handleDialogRefresh() {
  1152. this.template.table.getdataListParm.parammaps.ccname = ''
  1153. this.template.table.getdataListParm.parammaps.fttype = ''
  1154. this.template.table.getdataListParm.parammaps.enable = ''
  1155. this.template.table.getdataListParm.parammaps.tname = ''
  1156. this.template.table.getdataListParm.parammaps.remark = ''
  1157. this.template.table.getdataListParm.parammaps.source = ''
  1158. this.template.table.getdataListParm.offset = 1
  1159. this.getTemplateDialogList()
  1160. },
  1161. // 配方记录-模板行点击
  1162. tableRowClickDialog(row, column, event) {
  1163. console.log('配方记录-模板行点击')
  1164. this.isDetailDialog = true
  1165. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1166. this.getDialogList()
  1167. this.getDownList()
  1168. },
  1169. getDialogList() {
  1170. this.template.table2.listLoading = true
  1171. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1172. console.log('table数据', response.data.list)
  1173. if (response.data.list !== null) {
  1174. this.template.table2.list = response.data.list
  1175. this.template.table2.pageNum = response.data.pageNum
  1176. this.template.table2.pageSize = response.data.pageSize
  1177. this.template.table2.total = response.data.total
  1178. } else {
  1179. this.template.table2.list = []
  1180. }
  1181. setTimeout(() => {
  1182. this.template.table2.listLoading = false
  1183. }, 100)
  1184. })
  1185. },
  1186. handleDialogSearch2() {
  1187. console.log('点击了查询')
  1188. this.arrowDown2 = true
  1189. this.arrowUp2 = false
  1190. this.template.table2.getdataListParm.offset = 1
  1191. this.getDialogList2()
  1192. },
  1193. handleDialogRefresh2() {
  1194. console.log('点击了重置')
  1195. this.template.table2.getdataListParm.parammaps.fname = ''
  1196. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1197. this.template.table2.getdataListParm.parammaps.fweight = ''
  1198. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1199. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1200. this.template.table2.getdataListParm.parammaps.sort = ''
  1201. this.template.table2.getdataListParm.offset = 1
  1202. this.getDialogList2()
  1203. },
  1204. getDialogList2() {
  1205. this.template.table2.listLoading = true
  1206. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1207. console.log('table数据', response.data.list)
  1208. if (response.data.list !== null) {
  1209. this.template.table2.list = response.data.list
  1210. this.template.table2.pageNum = response.data.pageNum
  1211. this.template.table2.pageSize = response.data.pageSize
  1212. this.template.table2.total = response.data.total
  1213. } else {
  1214. this.template.table2.list = []
  1215. }
  1216. this.$nextTick(function() {
  1217. window.scrollTo({
  1218. 'top': this.$refs.templateDialog.clientHeight
  1219. })
  1220. })
  1221. setTimeout(() => {
  1222. this.template.table2.listLoading = false
  1223. }, 100)
  1224. })
  1225. },
  1226. handleImport() {
  1227. console.log('点击了导入')
  1228. },
  1229. handleExport() {
  1230. console.log('点击了导出')
  1231. },
  1232. changeDate() {
  1233. this.getTemplateDialogList()
  1234. },
  1235. // 应用
  1236. handleApplication() {
  1237. console.log('点击了应用')
  1238. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1239. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1240. }).then(() => {
  1241. this.requestParam.name = 'applyFTdate'
  1242. this.requestParam.parammaps = {}
  1243. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1244. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1245. PostDataByName(this.requestParam).then(response => {
  1246. if (response.msg === 'fail') {
  1247. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1248. } else {
  1249. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1250. this.getTemplateDialogList()
  1251. this.getList()
  1252. }
  1253. })
  1254. }).catch(() => {
  1255. this.$message({ type: 'info', message: '已取消应用' })
  1256. })
  1257. },
  1258. // 模板行点击
  1259. tableRowClick(row, column, event) {
  1260. console.log(row, column, event)
  1261. for (let i = 0; i < this.table.list.length; i++) {
  1262. if (this.table.list[i].Edit == true) {
  1263. return false
  1264. }
  1265. }
  1266. if (column.label !== '操作') {
  1267. this.isDetail = true // 点击行显示详情
  1268. this.table2.getdataListParm.parammaps.ftid = row.id
  1269. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1270. this.getList2()
  1271. this.getDownList()
  1272. }
  1273. },
  1274. // -------------------详情-----------------------------
  1275. // 获取是否显示是否锁定牛头数
  1276. getIsLockCount() {
  1277. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1278. console.log(response.data.list)
  1279. if (response.data.list[0].inforvalue == 0) {
  1280. this.lockCount.isLockCount = false
  1281. } else {
  1282. this.lockCount.isLockCount = true
  1283. }
  1284. })
  1285. },
  1286. // 详情
  1287. getList2() {
  1288. this.table2.listLoading = true
  1289. GetDataByName(this.table2.getdataListParm).then(response => {
  1290. console.log('table数据', response.data.list)
  1291. if (response.data.list !== null) {
  1292. for (let i = 0; i < response.data.list.length; i++) {
  1293. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1294. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1295. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1296. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1297. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1298. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1299. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1300. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1301. }
  1302. this.table2.list = response.data.list
  1303. this.table2.pageNum = response.data.pageNum
  1304. this.table2.pageSize = response.data.pageSize
  1305. this.table2.total = response.data.total
  1306. this.rowDrop()
  1307. } else {
  1308. this.table2.list = []
  1309. }
  1310. this.$nextTick(function() {
  1311. console.log(this.$refs)
  1312. console.log(this.$refs.template.clientHeight)
  1313. window.scrollTo({
  1314. 'top': this.$refs.template.clientHeight
  1315. })
  1316. })
  1317. setTimeout(() => {
  1318. this.table2.listLoading = false
  1319. }, 100)
  1320. })
  1321. },
  1322. // 行拖拽
  1323. rowDrop() {
  1324. console.log(1111)
  1325. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1326. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1327. // this.sorTable()
  1328. const that = this
  1329. // Sortable.create(tbody, {
  1330. var sortable = Sortable.create(tbody, {
  1331. disabled: that.dropState,
  1332. onChoose({ newIndex, oldIndex }) {
  1333. if (that.dropState == true) {
  1334. sortable.destroy()
  1335. }
  1336. },
  1337. onEnd({ newIndex, oldIndex }) {
  1338. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1339. that.table2.list.splice(newIndex, 0, currRow)
  1340. console.log('索引', newIndex)
  1341. console.log('拖动数据', currRow)
  1342. console.log('上', that.table2.list[newIndex - 1])
  1343. console.log('下', that.table2.list[newIndex + 1])
  1344. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1345. for (let i = 0; i < that.table2.list.length; i++) {
  1346. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1347. }
  1348. currRow.sort = 0
  1349. currRow.feedgroup = currRow.fname
  1350. console.log('拖动至最上方无值')
  1351. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1352. currRow.sort = that.table2.list[newIndex - 1].sort
  1353. console.log('拖动值顺序等于上值顺序')
  1354. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1355. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1356. currRow.feedgroup = currRow.fname
  1357. console.log('拖动至最下方无值')
  1358. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1359. currRow.sort == that.table2.list[newIndex + 1].sort
  1360. console.log('拖动值顺序等于下值顺序')
  1361. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1362. currRow.sort = that.table2.list[newIndex - 1].sort
  1363. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1364. console.log('拖动至上下顺序一致')
  1365. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1366. console.log('上下')
  1367. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1368. console.log(newIndex)
  1369. for (let i = newIndex; i < that.table2.list.length; i++) {
  1370. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1371. }
  1372. }
  1373. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1374. currRow.feedgroup = currRow.fname
  1375. console.log(that.table2.list[newIndex + 1].sort)
  1376. }
  1377. that.requestParam = {}
  1378. that.requestParam.common = { 'returnmap': '0' }
  1379. that.requestParam.data = []
  1380. that.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': that.table2.list }}
  1381. that.requestParam.data[0].children = []
  1382. that.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1383. id: '@insertSpotList.id',
  1384. pastureid: '@insertSpotList.pastureid',
  1385. sort: '@insertSpotList.sort',
  1386. feedgroup: '@insertSpotList.feedgroup'
  1387. }}
  1388. ExecDataByConfig(that.requestParam).then(response => {
  1389. console.log('顺序切换保存发送参数', that.requestParam)
  1390. if (response.msg === 'fail') {
  1391. that.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1392. } else {
  1393. that.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1394. that.getList2()
  1395. }
  1396. })
  1397. }
  1398. })
  1399. console.log(sortable.option('disabled'))
  1400. },
  1401. handleSearch2() {
  1402. console.log('点击了查询')
  1403. this.arrowDown2 = true
  1404. this.arrowUp2 = false
  1405. this.table2.getdataListParm.offset = 1
  1406. this.getList2()
  1407. },
  1408. handleRefresh2() {
  1409. console.log('点击了重置')
  1410. this.table2.getdataListParm.parammaps.fname = ''
  1411. this.table2.getdataListParm.parammaps.feedgroup = ''
  1412. this.table2.getdataListParm.parammaps.fweight = ''
  1413. this.table2.getdataListParm.parammaps.autosecondname = ''
  1414. this.table2.getdataListParm.parammaps.islockcount = '0'
  1415. this.table2.getdataListParm.parammaps.sort = ''
  1416. this.table2.getdataListParm.offset = 1
  1417. this.getList2()
  1418. },
  1419. // 详情新增
  1420. handleCreate2() {
  1421. console.log('点击了详情新增', this.table2.list)
  1422. // 编辑true/不可编辑false
  1423. // 新增操true,编辑false,编辑保存false
  1424. console.log(11)
  1425. for (let i = 0; i < this.table2.list.length; i++) {
  1426. if (this.table2.list[i].Edit === true) {
  1427. console.log(123)
  1428. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1429. return false
  1430. }
  1431. }
  1432. console.log(this.table2.list)
  1433. if (this.table2.list.length == 0) {
  1434. var mysort = 0
  1435. } else {
  1436. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1437. }
  1438. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  1439. console.log(this.table2.list)
  1440. },
  1441. changeFname(item, row) {
  1442. console.log(item, row)
  1443. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1444. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1445. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1446. this.table2.temp.preftid = '0'
  1447. } else {
  1448. this.table2.temp.preftid = item
  1449. }
  1450. if (row.sort == '') {
  1451. row.feedgroup = this.table2.temp.fname
  1452. } else {
  1453. if (row.isCreate == true) { // 新增状态下
  1454. for (let i = 1; i < this.table2.list.length; i++) {
  1455. if (this.table2.list[i].sort == row.sort) {
  1456. console.log(this.table2.list[i])
  1457. row.feedgroup = this.table2.list[i].feedgroup
  1458. break
  1459. } else {
  1460. row.feedgroup = this.table2.temp.fname
  1461. }
  1462. }
  1463. } else if (row.isUpdateSave == true) { // 编辑状态下
  1464. var Arr = []
  1465. for (let i = 0; i < this.table2.list.length; i++) {
  1466. Arr.push(this.table2.list[i].sort)
  1467. }
  1468. var Count = 0
  1469. for (let i = 0; i < Arr.length; i++) {
  1470. if (Arr[i] == row.sort) {
  1471. Count++
  1472. }
  1473. }
  1474. for (let i = 0; i < this.table2.list.length; i++) {
  1475. if (Count > 1) {
  1476. row.feedgroup = this.table2.list[i].feedgroup
  1477. console.log(111, this.table2.list[i].feedgroup)
  1478. break
  1479. } else if (Count == 1) {
  1480. row.feedgroup = this.table2.temp.fname
  1481. console.log(222, this.table2.temp.fname)
  1482. }
  1483. }
  1484. }
  1485. }
  1486. },
  1487. blurSort(row) {
  1488. if (row.isCreate == true) {
  1489. if (row.sort !== '') {
  1490. for (let i = 1; i < this.table2.list.length; i++) {
  1491. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1492. row.feedgroup = this.table2.list[i].feedgroup
  1493. return false
  1494. } else {
  1495. row.feedgroup = row.fname
  1496. }
  1497. }
  1498. } else {
  1499. row.feedgroup = row.fname
  1500. }
  1501. } else if (row.isUpdateSave == true) {
  1502. if (row.sort !== '') {
  1503. for (let i = 0; i < this.table2.list.length; i++) {
  1504. if (this.table2.list[i].sort == row.sort) {
  1505. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1506. if (this.table2.list[i].id !== row.id) {
  1507. row.isGroupDisabled = true
  1508. row.feedgroup = this.table2.list[i].feedgroup
  1509. break
  1510. }
  1511. } else {
  1512. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1513. row.isGroupDisabled = true
  1514. row.feedgroup = row.fname
  1515. }
  1516. }
  1517. } else {
  1518. row.feedgroup = row.fname
  1519. }
  1520. }
  1521. },
  1522. createData2(row) {
  1523. console.log('点击了详情新增保存', row)
  1524. this.table2.temp.pastureid = Cookies.get('pastureid')
  1525. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1526. this.table2.temp.fid = row.fid
  1527. this.table2.temp.fname = this.table2.temp.fname
  1528. this.table2.temp.fweight = row.fweight
  1529. this.table2.temp.islockcount = row.islockcount
  1530. this.table2.temp.sort = row.sort
  1531. this.table2.temp.feedgroup = row.feedgroup
  1532. this.table2.temp.preftid = this.table2.temp.preftid
  1533. this.table2.temp.autosecond = row.autosecond
  1534. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1535. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1536. return false
  1537. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1538. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1539. return false
  1540. } else if (this.table2.temp.fid == '') {
  1541. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1542. return false
  1543. } else if (this.table2.temp.fweight == '') {
  1544. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1545. return false
  1546. } else if (this.table2.temp.autosecond == '') {
  1547. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1548. return false
  1549. }
  1550. if (this.table2.temp.sort !== '') {
  1551. this.table2.temp.sort = this.table2.temp.sort
  1552. } else {
  1553. console.log(this.table2.list.length)
  1554. if (this.table2.list.length == 1) {
  1555. this.table2.temp.sort = 0
  1556. } else {
  1557. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1558. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1559. }
  1560. }
  1561. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1562. if (parseInt(this.table2.temp.preftid) > 0) {
  1563. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1564. return false
  1565. }
  1566. }
  1567. // 校验顺序是否>=0
  1568. var ruleSort = /^\d+$/
  1569. if (!ruleSort.test(this.table2.temp.sort)) {
  1570. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1571. return false
  1572. }
  1573. // 检验重量>0
  1574. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1575. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1576. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1577. return false
  1578. }
  1579. this.isokDisable = true
  1580. setTimeout(() => {
  1581. this.isokDisable = false
  1582. }, 1000)
  1583. this.requestParam.common = { 'returnmap': '0' }
  1584. this.requestParam.data = []
  1585. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1586. pastureid: this.table2.temp.pastureid,
  1587. ftid: this.table2.getdataListParm.parammaps.ftid,
  1588. fid: row.fid,
  1589. fname: this.table2.temp.fname,
  1590. fweight: row.fweight,
  1591. islockcount: row.islockcount,
  1592. sort: row.sort,
  1593. feedgroup: row.feedgroup,
  1594. preftid: this.table2.temp.preftid,
  1595. autosecond: row.autosecond
  1596. }}
  1597. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1598. pastureid: this.table2.temp.pastureid,
  1599. ftid: this.table2.getdataListParm.parammaps.ftid,
  1600. type: this.table2.getdataListParm.parammaps.fttypeid
  1601. }}
  1602. ExecDataByConfig(this.requestParam).then(response => {
  1603. console.log('新增保存发送参数', this.requestParam)
  1604. if (response.msg !== 'fail') {
  1605. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1606. this.getList2()
  1607. } else {
  1608. failproccess(response, this.$notify)
  1609. }
  1610. })
  1611. },
  1612. createCancel2(row) {
  1613. console.log('点击了详情新增取消')
  1614. for (let i = 0; i < this.table2.list.length; i++) {
  1615. if (row.myId === this.table2.list[i].myId) {
  1616. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  1617. }
  1618. if (listIndex > -1) {
  1619. this.table2.list.splice(listIndex, 1)
  1620. return
  1621. }
  1622. }
  1623. this.getDialogList()
  1624. },
  1625. // 详情编辑
  1626. handleUpdate2(row) {
  1627. console.log('详情编辑', row)
  1628. this.dropState = true
  1629. row.isGroupDisabled = false
  1630. row.islockcount = String(row.islockcount)
  1631. row.fid = String(row.fid)
  1632. row.autosecond = String(row.autosecond)
  1633. this.table2.temp.fname = row.fname
  1634. this.table2.temp.preftid = row.preftid
  1635. const rowArr = []
  1636. for (let i = 0; i < this.table2.list.length; i++) {
  1637. if (this.table2.list[i].Edit == true) {
  1638. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1639. return false
  1640. }
  1641. rowArr.push(this.table2.list[i].sort)
  1642. }
  1643. var count = 0
  1644. for (let i = 0; i < rowArr.length; i++) {
  1645. if (rowArr[i] == row.sort) {
  1646. count++
  1647. }
  1648. }
  1649. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  1650. if (count == 1) {
  1651. // 饲料组编辑false,不可编辑true
  1652. row.groupEdit = false
  1653. row.groupNoEdit = true
  1654. // 编辑true,不可编辑false
  1655. row.Edit = true
  1656. row.NoEdit = false
  1657. // 新增false,编辑false,编辑保存true
  1658. row.isCreate = false
  1659. row.isUpdate = false
  1660. row.isUpdateSave = true
  1661. } else if (count > 1) {
  1662. // 饲料组编辑true,不可编辑false
  1663. row.groupEdit = true
  1664. row.groupNoEdit = false
  1665. console.log(222)
  1666. // 编辑true,不可编辑false
  1667. row.Edit = true
  1668. row.NoEdit = false
  1669. // 新增false,编辑false,编辑保存true
  1670. row.isCreate = false
  1671. row.isUpdate = false
  1672. row.isUpdateSave = true
  1673. return false
  1674. }
  1675. },
  1676. updateData2(row) {
  1677. console.log('点击了详情编辑保存111', row)
  1678. this.isokDisable = true
  1679. setTimeout(() => {
  1680. this.isokDisable = false
  1681. }, 1000)
  1682. this.table2.temp.pastureid = row.pastureid
  1683. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1684. this.table2.temp.fid = row.fid
  1685. this.table2.temp.fname = this.table2.temp.fname
  1686. this.table2.temp.fweight = row.fweight
  1687. this.table2.temp.islockcount = row.islockcount
  1688. this.table2.temp.sort = row.sort
  1689. this.table2.temp.feedgroup = row.feedgroup
  1690. this.table2.temp.preftid = this.table2.temp.preftid
  1691. this.table2.temp.autosecond = row.autosecond
  1692. this.table2.temp.id = row.id
  1693. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1694. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1695. return false
  1696. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1697. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1698. return false
  1699. } else if (this.table2.temp.fid == '') {
  1700. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1701. return false
  1702. } else if (this.table2.temp.fweight == '') {
  1703. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1704. return false
  1705. } else if (this.table2.temp.autosecond == '') {
  1706. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1707. return false
  1708. }
  1709. if (this.table2.temp.sort !== '') {
  1710. this.table2.temp.sort = this.table2.temp.sort
  1711. } else {
  1712. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1713. }
  1714. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1715. if (parseInt(this.table2.temp.preftid) > 0) {
  1716. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1717. return false
  1718. }
  1719. }
  1720. // 校验顺序是否>=0
  1721. var ruleSort = /^\d+$/
  1722. if (!ruleSort.test(this.table2.temp.sort)) {
  1723. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1724. return false
  1725. }
  1726. // 检验重量>0
  1727. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1728. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1729. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1730. return false
  1731. }
  1732. this.requestParam.common = { 'returnmap': '0' }
  1733. this.requestParam.data = []
  1734. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  1735. pastureid: row.pastureid,
  1736. ftid: this.table2.getdataListParm.parammaps.ftid,
  1737. fid: row.fid,
  1738. fname: this.table2.temp.fname,
  1739. fweight: row.fweight,
  1740. islockcount: row.islockcount,
  1741. sort: row.sort,
  1742. feedgroup: row.feedgroup,
  1743. preftid: this.table2.temp.preftid,
  1744. autosecond: row.autosecond,
  1745. id: row.id
  1746. }}
  1747. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1748. pastureid: row.pastureid,
  1749. ftid: this.table2.getdataListParm.parammaps.ftid,
  1750. type: this.table2.getdataListParm.parammaps.fttypeid
  1751. }}
  1752. this.requestParam.data[2] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  1753. pastureid: row.pastureid,
  1754. ftid: this.table2.getdataListParm.parammaps.ftid,
  1755. sort: row.sort,
  1756. feedgroup: row.feedgroup
  1757. }}
  1758. ExecDataByConfig(this.requestParam).then(response => {
  1759. console.log('新增保存发送参数', this.requestParam)
  1760. if (response.msg !== 'fail') {
  1761. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1762. this.getList2()
  1763. this.dropState = false
  1764. } else {
  1765. failproccess(response, this.$notify)
  1766. }
  1767. })
  1768. },
  1769. updateCancel2(row) {
  1770. console.log('点击了详情编辑取消')
  1771. // 饲料组编辑false,不可编辑true
  1772. row.groupEdit = false
  1773. row.groupNoEdit = true
  1774. // 编辑false,不可编辑true
  1775. row.Edit = false
  1776. row.NoEdit = true
  1777. // 新增false,编辑true,编辑保存false
  1778. row.isCreate = false
  1779. row.isUpdate = true
  1780. row.isUpdateSave = false
  1781. this.getList2()
  1782. this.dropState = false
  1783. },
  1784. // 详情删除
  1785. handleRowDelete2(row) {
  1786. console.log('点击了行内删除')
  1787. MessageBox.confirm('是否确认删除此信息?', {
  1788. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1789. }).then(() => {
  1790. this.requestParam.common = { 'returnmap': '0' }
  1791. this.requestParam.data = []
  1792. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1793. pastureid: row.pastureid,
  1794. id: row.id
  1795. }}
  1796. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1797. pastureid: row.pastureid,
  1798. ftid: this.table2.getdataListParm.parammaps.ftid,
  1799. type: this.table2.getdataListParm.parammaps.fttypeid
  1800. }}
  1801. ExecDataByConfig(this.requestParam).then(response => {
  1802. console.log('新增保存发送参数', this.requestParam)
  1803. if (response.msg === 'fail') {
  1804. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1805. } else {
  1806. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1807. this.getList2()
  1808. }
  1809. })
  1810. }).catch(() => {
  1811. this.$message({ type: 'info', message: '已取消删除' })
  1812. })
  1813. },
  1814. handleSelectionChange2(val) {
  1815. console.log('勾选数据', val)
  1816. this.selectList2 = val
  1817. },
  1818. handleDelete2() {
  1819. console.log('点击了删除')
  1820. if (this.selectList2.length == 0) {
  1821. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  1822. } else {
  1823. MessageBox.confirm('是否确认删除此信息?', {
  1824. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1825. }).then(() => {
  1826. console.log(this.selectList)
  1827. this.requestParam.common = { 'returnmap': '0' }
  1828. this.requestParam.data = []
  1829. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  1830. this.requestParam.data[0].children = []
  1831. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1832. id: '@insertSpotList.id',
  1833. pastureid: '@insertSpotList.pastureid'
  1834. }}
  1835. ExecDataByConfig(this.requestParam).then(response => {
  1836. console.log('删除保存发送参数', this.requestParam)
  1837. if (response.msg === 'fail') {
  1838. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1839. } else {
  1840. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1841. this.getList2()
  1842. }
  1843. })
  1844. })
  1845. }
  1846. },
  1847. // 拆分预混料
  1848. handleSplitPremix(row) {
  1849. console.log('点击了拆分预混料')
  1850. MessageBox.confirm('是否确认拆分当前预混料?', {
  1851. confirmButtonText: '确认',
  1852. cancelButtonText: '取消',
  1853. type: 'warning'
  1854. }).then(() => {
  1855. this.requestParam.name = 'splitFTpre'
  1856. this.requestParam.parammaps = {}
  1857. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  1858. this.requestParam.parammaps.preftid = row.preftid
  1859. this.requestParam.parammaps.ftdid = row.id
  1860. this.requestParam.parammaps.pastureid = row.pastureid
  1861. this.requestParam.parammaps.feedgroup = row.feedgroup
  1862. this.requestParam.parammaps.sort = row.sort
  1863. this.requestParam.parammaps.fweight = row.fweight
  1864. PostDataByName(this.requestParam).then(response => {
  1865. if (response.msg === 'fail') {
  1866. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1867. } else {
  1868. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1869. this.getList2()
  1870. }
  1871. })
  1872. }).catch(() => {
  1873. this.$message({
  1874. type: 'info',
  1875. message: '已取消删除'
  1876. })
  1877. })
  1878. },
  1879. // 合成预混料
  1880. handleSyntheticPremix() {
  1881. console.log('点击了合成预混料', this.selectList2)
  1882. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1883. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  1884. return false
  1885. } else {
  1886. if (this.selectList2.length > 1) {
  1887. for (let i = 0; i < this.selectList2.length; i++) {
  1888. if (parseInt(this.selectList2[i].preftid) > 0) {
  1889. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  1890. return false
  1891. }
  1892. }
  1893. if (this.selectList2[0].splitftpreid !== undefined) {
  1894. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  1895. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  1896. GetDataByName(this.detail.getdataListParm).then(response => {
  1897. if (response.data.list !== null) { // 不为空时得到比对数据
  1898. this.detail.list3 = response.data.list
  1899. const sortList = [] // 声明排序数组
  1900. var fweightSum = 0 // 总重量
  1901. for (let i = 0; i < this.selectList2.length; i++) {
  1902. const obj = {}
  1903. obj.fid = this.selectList2[i].fid
  1904. obj.fweight = this.selectList2[i].fweight
  1905. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  1906. sortList.push(obj)
  1907. }
  1908. // 排序
  1909. sortList.sort(function(a, b) {
  1910. return a.fid.localeCompare(b.fid)
  1911. })
  1912. var a = 0
  1913. if (this.detail.list3.length == sortList.length) {
  1914. for (let i = 0; i < this.detail.list3.length; i++) {
  1915. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(2) == (sortList[i].fweight / fweightSum).toFixed(2)) {
  1916. a++
  1917. }
  1918. }
  1919. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  1920. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  1921. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  1922. GetDataByName(this.detail.getdataListParm2).then(response => {
  1923. if (response.data.list !== null) {
  1924. this.detail.dialogStatus = 'SyntheticPremix'
  1925. this.detail.dialogFormVisible = true
  1926. this.detail.list = this.selectList2
  1927. this.detail.list2 = response.data.list
  1928. this.detail.disabled = true
  1929. setTimeout(() => {
  1930. this.detail.listLoading = false
  1931. }, 100)
  1932. } else {
  1933. this.detail.list2 = []
  1934. }
  1935. })
  1936. } else {
  1937. this.detail.dialogStatus = 'SyntheticPremix'
  1938. this.detail.dialogFormVisible = true
  1939. this.detail.list = this.selectList2
  1940. this.detail.disabled = false
  1941. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1942. setTimeout(() => {
  1943. this.detail.listLoading = false
  1944. }, 100)
  1945. }
  1946. } else {
  1947. this.detail.dialogStatus = 'SyntheticPremix'
  1948. this.detail.dialogFormVisible = true
  1949. this.detail.list = this.selectList2
  1950. this.detail.disabled = false
  1951. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1952. setTimeout(() => {
  1953. this.detail.listLoading = false
  1954. }, 100)
  1955. }
  1956. } else {
  1957. this.detail.list3 = []
  1958. this.detail.dialogStatus = 'SyntheticPremix'
  1959. this.detail.dialogFormVisible = true
  1960. this.detail.list = this.selectList2
  1961. this.detail.disabled = false
  1962. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1963. setTimeout(() => {
  1964. this.detail.listLoading = false
  1965. }, 100)
  1966. }
  1967. })
  1968. } else {
  1969. this.detail.dialogStatus = 'SyntheticPremix'
  1970. this.detail.dialogFormVisible = true
  1971. this.detail.list = this.selectList2
  1972. this.detail.disabled = false
  1973. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  1974. setTimeout(() => {
  1975. this.detail.listLoading = false
  1976. }, 100)
  1977. }
  1978. } else {
  1979. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  1980. return false
  1981. }
  1982. }
  1983. },
  1984. // 畜生类别
  1985. changeLivestockType2(item) {
  1986. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  1987. },
  1988. syntheticPremixData() {
  1989. console.log('点击了合成预混料确认')
  1990. if (this.detail.disabled == true) { // 原预混料
  1991. let sumFweight = 0
  1992. for (let i = 0; i < this.detail.list.length; i++) {
  1993. sumFweight += parseFloat(this.detail.list[i].fweight)
  1994. }
  1995. sumFweight = sumFweight.toFixed(2)
  1996. this.isokDisable = true
  1997. setTimeout(() => {
  1998. this.isokDisable = false
  1999. }, 1000)
  2000. this.requestParam.common = { 'returnmap': '0' }
  2001. this.requestParam.data = []
  2002. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2003. this.requestParam.data[0].children = []
  2004. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2005. pastureid: '@insertSpotList.pastureid',
  2006. id: '@insertSpotList.id'
  2007. }}
  2008. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2009. this.requestParam.data[1].children = []
  2010. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2011. pastureid: Cookies.get('pastureid'),
  2012. ftid: this.table2.getdataListParm.parammaps.ftid,
  2013. fid: this.detail.list2[0].id,
  2014. fname: '@insertSpotList2.tname',
  2015. fweight: sumFweight,
  2016. islockcount: '0',
  2017. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2018. feedgroup: '@insertSpotList2.tname',
  2019. preftid: this.detail.list2[0].id,
  2020. autosecond: this.detail.list[0].autosecond
  2021. }}
  2022. ExecDataByConfig(this.requestParam).then(response => {
  2023. console.log('合成预混料保存发送参数', this.requestParam)
  2024. if (response.msg === 'fail') {
  2025. const tname = new RegExp("key 'tname'")
  2026. if (tname.test(response.data)) {
  2027. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2028. } else {
  2029. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2030. }
  2031. } else {
  2032. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2033. this.detail.dialogFormVisible = false
  2034. this.getList()
  2035. this.getList2()
  2036. this.getDownList()
  2037. }
  2038. })
  2039. } else { // 现生成预混料
  2040. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2041. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2042. return false
  2043. } else if (this.detail.list2[0].tname == '') {
  2044. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2045. return false
  2046. } else if (this.detail.list2[0].ccid == '') {
  2047. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2048. return false
  2049. }
  2050. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2051. if (pattern.test(this.detail.list2[0].tname)) {
  2052. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2053. return false
  2054. }
  2055. let sumFweight = 0
  2056. for (let i = 0; i < this.detail.list.length; i++) {
  2057. sumFweight += parseFloat(this.detail.list[i].fweight)
  2058. }
  2059. sumFweight = sumFweight.toFixed(2)
  2060. console.log(sumFweight)
  2061. this.isokDisable = true
  2062. setTimeout(() => {
  2063. this.isokDisable = false
  2064. }, 1000)
  2065. this.requestParam.common = { 'returnmap': '0' }
  2066. this.requestParam.data = []
  2067. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2068. pastureid: Cookies.get('pastureid'),
  2069. tcode: this.detail.list2[0].tcode,
  2070. tname: this.detail.list2[0].tname,
  2071. tcolor: this.detail.list2[0].tcolor,
  2072. ccid: this.detail.list2[0].ccid,
  2073. ccname: this.detail.list2[0].ccname,
  2074. fttype: this.detail.list2[0].fttype,
  2075. fttypeid: this.detail.list2[0].fttypeid,
  2076. source: this.detail.list2[0].source,
  2077. remark: this.detail.list2[0].remark,
  2078. enable: this.detail.list2[0].enable
  2079. }}
  2080. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2081. this.requestParam.data[1].children = []
  2082. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2083. pastureid: '@insertSpotList.pastureid',
  2084. ftid: '@insertFT.LastInsertId',
  2085. fid: '@insertSpotList.fid',
  2086. fname: '@insertSpotList.fname',
  2087. fweight: '@insertSpotList.fweight',
  2088. islockcount: '@insertSpotList.islockcount',
  2089. sort: '@insertSpotList.sort',
  2090. feedgroup: '@insertSpotList.feedgroup',
  2091. preftid: '@insertSpotList.preftid',
  2092. autosecond: '@insertSpotList.autosecond'
  2093. }}
  2094. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2095. pastureid: '@insertSpotList.pastureid',
  2096. id: '@insertSpotList.id'
  2097. }}
  2098. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2099. this.requestParam.data[2].children = []
  2100. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2101. pastureid: Cookies.get('pastureid'),
  2102. ftid: this.table2.getdataListParm.parammaps.ftid,
  2103. fid: '@insertFT.LastInsertId',
  2104. fname: '@insertSpotList2.tname',
  2105. fweight: sumFweight,
  2106. islockcount: '0',
  2107. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2108. feedgroup: '@insertSpotList2.tname',
  2109. preftid: '@insertFT.LastInsertId',
  2110. autosecond: this.detail.list[0].autosecond
  2111. }}
  2112. ExecDataByConfig(this.requestParam).then(response => {
  2113. console.log('合成预混料保存发送参数', this.requestParam)
  2114. if (response.msg === 'fail') {
  2115. const tname = new RegExp("key 'tname'")
  2116. if (tname.test(response.data)) {
  2117. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2118. } else {
  2119. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2120. }
  2121. } else {
  2122. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2123. this.detail.dialogFormVisible = false
  2124. this.getList()
  2125. this.getList2()
  2126. this.getDownList()
  2127. }
  2128. })
  2129. }
  2130. }
  2131. }
  2132. }
  2133. </script>
  2134. <style lang="scss" scoped>
  2135. .search{margin-top:10px;}
  2136. .table{margin-top:10px;}
  2137. .table2{margin-top:10px;}
  2138. $width:350px;
  2139. $left:325px;
  2140. .selectInput{
  2141. position: relative;
  2142. display: inline-block;
  2143. .Input{width: $width;position: relative;}
  2144. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2145. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2146. .selectUl{
  2147. 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;
  2148. li{
  2149. 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;
  2150. a{float:left;width: 80px;}
  2151. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2152. }
  2153. }
  2154. }
  2155. .template{
  2156. background: #fff;
  2157. position: relative;
  2158. .recipeTemplate{
  2159. width: 72px;
  2160. height: 70px;
  2161. position: absolute;
  2162. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2163. right: 0;
  2164. top: 0;
  2165. margin: 0;
  2166. }
  2167. }
  2168. .detail{
  2169. background: #fff;
  2170. position: relative;
  2171. .recipeDetail{
  2172. width: 72px;
  2173. height: 70px;
  2174. position: absolute;
  2175. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2176. right: 0;
  2177. top: 0;
  2178. margin: 0;
  2179. }
  2180. }
  2181. .templateDialog{
  2182. background: #fff;
  2183. position: relative;
  2184. .recipeTemplate{
  2185. width: 72px;
  2186. height: 70px;
  2187. position: absolute;
  2188. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2189. right: 0;
  2190. top: 0;
  2191. margin: 0;
  2192. }
  2193. }
  2194. .detailDialog{
  2195. background: #fff;
  2196. position: relative;
  2197. .recipeDetail{
  2198. width: 72px;
  2199. height: 70px;
  2200. position: absolute;
  2201. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2202. right: 0;
  2203. top: 0;
  2204. margin: 0;
  2205. }
  2206. }
  2207. </style>